Application.application.nativeWindow.activate () problem on Windows

I have an AIR application with a system tray icon. When you click on it, the application is displayed and activated. This works as expected when the application is hidden (docked), however, if I select another application so that my application is in the background, clicking on the icon in the taskbar does nothing.

Oddly enough, I also have a context menu on the icon in the system tray, in which there is a recovery option that calls the same event handler as ScreenMouseEvent.CLICK, but it works.

I expect that this has something to do with the context menu that changes focus, maybe this is a mistake in how AIR works with the system tray, maybe this is just what I am missing. It would be nice to know if this is the case.

Thanks in advance

Rob

+4
source share
1 answer
//instead of just calling activate(); //call nativeApplication.activate() //or even better nativeApplication.activate(nativeWindow); 

Update based on OP input: if you have multiple windows open for the application, use:

 nativeApplication.activate(nativeApplication.openedWindows[0]); 

If you are not in the main WindowedApplication class, you can use the static NativeApplication.nativeApplication property to get a reference to a singleton object.

WindowedApplication.activate ()

Activates the underlying NativeWindow (even if this application is not active).

NativeApplication.activate (window: NativeWindow = null)

Activates this application. If the operating system allows you to activate, then the specified window is activated and displayed on the foreground desktop; that is, in front of windows of other applications. (If the window parameter is NULL, then the visible window of this application is activated.)

liveocs is not clear why this is happening. He says that activate() will activate the main window of its own - one would expect it to be moved to the front when it is activated, but that will not happen.

+3
source

All Articles