Actionscript 3 Flex topLevelApplication和SuperTabNavigator鼠标事件处理程序
我正在使用flexActionscript 3 Flex topLevelApplication和SuperTabNavigator鼠标事件处理程序,actionscript-3,apache-flex,actionscript,mouseevent,Actionscript 3,Apache Flex,Actionscript,Mouseevent,我正在使用flexSuperTabNavigator,希望关闭选项卡,检查是否按下了控制按钮。我试过: public static var CONTROL_PRESSED:Boolean = false; public function init():void { var clickListener:Function = function _clickListener(event:MouseEvent):void{ trace(even
SuperTabNavigator
,希望关闭选项卡,检查是否按下了控制按钮。我试过:
public static var CONTROL_PRESSED:Boolean = false;
public function init():void {
var clickListener:Function = function _clickListener(event:MouseEvent):void{
trace(event.ctrlKey);
if(event.ctrlKey){
CONTROL_PRESSED = true;
}else{
CONTROL_PRESSED = false;
}
};
FlexGlobals.topLevelApplication.addEventListener(MouseEvent.CLICK, clickListener);
}
这样做的问题是,除了在选项卡上,应用程序中的任何地方都会调用鼠标单击。我也尝试了相同的代码,但是
addEventListener(MouseEvent.CLICK,clickListener)
将侦听器添加到SuperTabNavigator
中,但根本不起作用。还有其他方法捕捉鼠标点击吗?这是因为SuperTabNavigator
有一个隐藏鼠标事件的专用鼠标点击处理程序函数:
private function closeClickHandler(event:MouseEvent):void {
if(this.enabled) {
dispatchEvent(new Event(CLOSE_TAB_EVENT));
}
event.stopImmediatePropagation();
event.stopPropagation();
}
您需要修改SuperTabNavigator
源中的SuperTab
类,以使用所需数据而不是普通的新事件(CLOSE\u TAB\u Event)
分派一些CustomEvent
然后更改SuperTabBar
中的onCloseTabClicked
功能,了解您的CustomEvent
。然后,您可以将其传递给应用程序代码(可能通过将其添加到SuperTabEvent
)