简体   繁体   English

如何触发tree itemClick事件,在Flex3 Air中设置Tree.selectedItem

[英]How to Fire tree itemClick event on, setting Tree.selectedItem in Flex3 Air

I am working on Air application,i had a problem on Tree control. 我正在开发Air应用程序,我在树控制方面遇到问题。

Iam adding nodes for the tree dynamically, while adding nodes to the tree i am setting 我动态地为树添加节点,同时将节点添加到我正在设置的树中

Tree.selectedItem as present added node. Tree.selectedItem作为当前添加的节点。 after that i need to fire Tree.itemClick event handler method also. 之后,我还需要触发Tree.itemClick事件处理程序方法。

how can i call event handler method as a common method. 我如何才能将事件处理程序方法称为常用方法。 in Flex3 在Flex3中

You can either call the method like you call any other method (pass null for the argument) or you can call dispatchEvent on the Tree to invoke the event handler automatically. 您可以像调用其他任何方法一样调用方法(为参数传递null ),也可以在Tree上调用dispatchEvent来自动调用事件处理程序。

If the event handler function is added through mxml and is not expecting the event as its argument, or it is added with AS but not actually using the event parameter, you can call it like you call any other function. 如果事件处理程序函数是通过mxml添加的,并且不希望事件作为其参数,或者它是与AS一起添加的,但实际上并未使用event参数,则可以像调用任何其他函数一样调用它。

private function itemClickHandler(event:ListEvent):void
{
  //code doesn't use event
}
//call it with a null
itemClickHandler(null);

//OR

private function itemClickHandler(event:ListEvent = null):void
{
  //code doesn't use event
}
itemClickHandler();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM