PDA

View Full Version : Detecting Window Focus Loss + Application Window Size



Ken L
December 21st, 2017, 23:20
I'm trying to make a window that can close itself after focus loss, or whenever the window is 'no longer on top'. To do this I'm looking for some kind of event I can hook into that fires when the window isn't an area of focus, or is no longer the top most window.

Next, I'm looking to get the size of the application window so I can do some manipulations on a desktop element, I don't see an obvious way to get it.

Bidmaron
December 22nd, 2017, 02:45
I'm trying to make a window that can close itself after focus loss, or whenever the window is 'no longer on top'. To do this I'm looking for some kind of event I can hook into that fires when the window isn't an area of focus, or is no longer the top most window.


I have wracked my brain many times to try to synthesize some kind of focus lost detection. There is no event, and I haven't figured out a way to synthesize it.



Next, I'm looking to get the size of the application window so I can do some manipulations on a desktop element, I don't see an obvious way to get it.

I haven't ever looked into this. Not aware you can do it directly, and I haven't given it any thought to figure out a kluge.

Moon Wizard
December 22nd, 2017, 03:01
The API in FG does not provide that event, or that information.

Regards,
JPG

Ken L
December 23rd, 2017, 10:15
You can simulate the first i've found by manipulating the onRelease or onClick of each control within the window to close the 'context' window. In addition, a little check in onClose to clean it if the window itself is closed. It requires however that every control within that window to be modified to 'watch out' for that window in terms of checking for its existence and closing it if so. For large encompassing controls like an image control this is doable, for something akin to a charactersheet, this is cumbersome and not worth it.

The second I've thought about creating an invisible, disabled desktop panel that attempts to size to the application window, (filling the entire area) and then getting the size of this element. I haven't tried it yet so I'm not entirely sure.

Bidmaron
December 23rd, 2017, 17:08
Good ideas, and I have experimented along the lines of your first one, but I too decided it was just too hard to implement, and it could clash with other extensions.

Your second idea sounds doable though.