我想获得鼠标单击屏幕坐标(通过单击AIR应用程序窗口外部)
我尝试了以下操作,但是我没有得到任何东西,似乎没有调度ScreenMouseEvent.CLICK事件。
public function Main():void
{
if (NativeApplication.supportsSystemTrayIcon)//testExpression return true
{
SystemTrayIcon(NativeApplication.nativeApplication.icon).
addEventListener(ScreenMouseEvent.CLICK, click);
}
}
private function click(e:ScreenMouseEvent):void
{
trace(e.screenX);//nothing displayed :(
}
答案 0 :(得分:0)
ScreenMouseEvent
仅由SystemTrayIcon
调度(仅限Windows / Linux)。从SystemTrayIcon
检索DockIcon
实例(MacOs的NativeApplication.nativeApplication.icon
)。
因此,在指定托盘图标图形后,您应该在此处附加事件监听器:
var sti:SystemTrayIcon = NativeApplication.nativeApplication.icon as SystemTrayIcon;
// Specifying an icon is obligatory on Windows - MacOs has a default icon
sti.bitmaps = [new IconAsset()]; // IconAsset = Embedded picture
sti.addEventListener(ScreenMouseEvent.CLICK, mouseClick);
请注意,screenX
生成的screenY
和ScreenMouseEvent
属性仅限于托盘中的图标区域,而不是整个桌面屏幕(不出所料,因为这是您添加的位置首先是事件。)