Dynamically set alwaysOnTop


#1

I want to set whether a lime.ui.Window can be always on top or not.
Digging through some lime documentations I found that lime.ui.WindowAttributes has the option awaysOnTop which sounds pretty much like what I want. Unfortunately WindowAttributes are for when windows are being created and I cannot access or change it’s value later on unless I wanted to destroy the window and recreate it.

Would there be a simple way to set this after the windows is created? Also would this work when using OpenFL as well?

Thanks in advance.


#2

I’m not sure we can do this dynamically in SDL (which we use for native windowing), but there is a window.focus () method, which may bring the window forward and give it focus. This isn’t quite the same as always on top (where it is on top, with or without focus) but it still may be useful for certain use cases?


#3

Thanks for answering @singmajesty!

Unfortunately, calling focus is not a solution I can use. apps running in the background would not be able to be accessed this way because window.focus() would unfocus any other window. this prevents some items being clicked and text input in other applications.

Since it doesn’t appear to be possible to dynamically change alwaysOnTop I believe I can close that window with window.close() and create a new one with application.createWindow(/*set alwaysOnTop*/);. The next step would be to add OpenFL to that window. I can probably do application.addModule(new openfl.display.Stage(/*newly created window here*/)); to add OpenFL to the window. I’m going to assume for now that lime would remove the previous Stage of the no longer existent window.

Does this sound about right? It might be messy and I probably shouldn’t switch setting alwaysOnTop too often but this sounds like it should work out being done occasionally. would there also be anyway to recycle OpenFL stages and swap in a new window? I suspect not but if there is… no harm in asking and finding out :smile:!