我有一個擴展到NativeWindow的FlexNativeWindow類。 我使用此方法在我的AIR應用程序上創建新窗口。 一切正常,但一些鍵盤交互不可用。Flex 4.5 - 自定義NativeWindow和問題
例如,焦點環繞textinput不可見。 Key Down和Up在DropDownList上不起作用。 TabOrder不能正常工作!
你能解釋爲什麼嗎?因爲我非常失望!
代碼來創建新的窗口
var wdetcorr:wDetailCorrespondant = new wDetailCorrespondant();
wdetcorr.monIdCorresp = correspDG.selectedItem.crIndex;
var wOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
wOptions.systemChrome = NativeWindowSystemChrome.NONE;
wOptions.transparent = false;
var fnwDetailPatient:FlexNativeWindow = new FlexNativeWindow(wdetcorr, wOptions);
fnwDetailPatient.active();
典約我自定義的NativeWindow
package fr.int.ui.windowSkin
{
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import mx.core.IUIComponent;
import mx.core.IVisualElement;
import mx.core.IVisualElementContainer;
import mx.core.UIComponent;
import mx.events.*;
import mx.managers.WindowedSystemManager;
[Event(name="creationComplete", type="mx.events.FlexEvent")]
public class FlexNativeWindow extends NativeWindow implements IFlexNativeWindow
{
private var _systemManager:WindowedSystemManager;
private var _content:UIComponent;
private var _window:IVisualElementContainer;
public function FlexNativeWindow(window:IVisualElementContainer, initOptions:NativeWindowInitOptions = null)
{
super(initOptions);
_window = window;
addEventListener(Event.ACTIVATE, windowActivateHandler);
}
public function addElement(control:IVisualElement):void
{
_window.addElement(control);
}
public function removeElement(control:IVisualElement):void
{
_window.removeElement(control);
}
private function windowActivateHandler(event:Event):void
{
event.preventDefault();
event.stopImmediatePropagation();
removeEventListener(Event.ACTIVATE, windowActivateHandler);
if (stage)
{
if (!_systemManager)
_systemManager = new WindowedSystemManager(IUIComponent(_window));
stage.addChild(_systemManager);
dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE));
stage.addEventListener(Event.RESIZE, windowResizeHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
}
}
private function keyDownListener (e:KeyboardEvent):void {
if (e.keyCode == Keyboard.ESCAPE) {
stage.nativeWindow.dispatchEvent(new Event("myEventClose", true));
stage.nativeWindow.close();
}
}
private function windowResizeHandler(event:Event):void
{
// prise en compte de la valeur mini
UIComponent(_window).height = stage.stageHeight;
UIComponent(_window).width = stage.stageWidth;
}
}
}
添加自己的WindowedSystemManager(並將其添加到舞臺)的目的是什麼?我認爲這可能會干擾Flex創建的那個。 –