ID:158057
 
Does anyone have a solid solution for determining window focus?

I tried Nadrews creative browser solution but it doesn't work for me because it requires the entire window to be of type "browser".

I need to set focus on a window after a user brings it to the foreground. They can click on any number of controls or the window itself to bring it forward.

ts
If you have time, make sure you go through EVERYTHING in the skin references (Help > Skin Ref) as there are some special behaviours/commands listed ... such as this section:


Special winget() calls

Calling the winget() proc with a blank or null control ID can return some values that belong to the whole program.

- winget(player, null, "focus") will return the ID of the control, if any, that currently has keyboard focus.
- winget(player, null, "windows") will return the IDs of the windows available in the program, separated by semicolons.
- winget(player, null, "menus") will return the IDs of the menus available in the program, separated by semicolons.
- winget(player, null, "macros") will return the IDs of the macros available in the program, separated by semicolons.




You can try seeing if clicking other elements, which gives it focus, changes the winget() value (as it says keyboard focus...)
In response to GhostAnime
Yeah, I did. Sorry I didn't mention it. It returns 0 all the time even when switching back and forth between windows.

ts
In response to Tsfreaks
Bug report time, then. Even more so if it actually really returns 0 (?), because by principle it should always be returning a text string (or at least null) and never a number.
In response to Tsfreaks
mob/proc/return_focus()
return winget(src, null, "focus")


It works fine for me.
In response to Sii
My windows are cloned and have no title bars. It didn't seem to matter if I clicked in the embedded browser controls or on the window itself, it always returned 0.

I might have to put a cloned demo together and see if I can repro it outside of my project.

ts
In response to Tsfreaks
My example returns what window I have focused and what sub unit I have focused in text format: window.subunit so the problem is on your end.
In response to Sii
It's a problem with BYOND, nonetheless, even if it doesn't occur for everyone/in every circumstance.
BTW, "sub unit" is called "control".