GetFocus without LoseFocus possible

Posted by Hve on Sat 29 Jan 2005 08:24 PM — 3 posts, 18,665 views.

Germany #0
If a world has focus and I switch to a dialog modal (i.e. Configuration[Alt+Enter], Find[Ctrl+F], Generate Character Name[Ctrl+Alt+N], or many others), the world does not lose focus (or at least the "Loose Focus" script function is not called).
If I close that dialog, however, the "Get Focus" function *is* called.
This way, a world may get focus several times in a row without losing focus inbetween.

Also, when clicking the Help button e.g. in the Configuration dialog, LooseFocus is called.
When switching to Mushclient again (still with configuration dialog in foreground), LooseFocus is called a second time.
Closing configuration dialog causes GetFocus (once).

Suggestion:
- Technically, these dialogs should all trigger "Loose Focus" in order to have matching Get and Loose counts.
At least it should be prevented that LooseFocus or GetFocus are called twice in a row (e.g. add a flag to each world window with the info, which of these may be called next)

- It might be desireable though to neither loose nor get focus in connection with these dialogs (i.e. the get/loose functions should be called only if the change of focus goes to/from another world or to/from another application but not to some "meta" part of the mushclient application)

- combination of the above: Have a configuration option
"[x] Call Get/Loose Focus for MUSHclient dialogs"
USA #1
Well.. I suspect that this is a Windows issue, not Mushclient. I seem to remember that Windows, in some circumstances, will cause multiple focus messages, depending on what sorts of windows you go between, etc. Its confusing and somewhat inconsistent, but I am not sure Nick can fix it.
Germany #2
Hm, I had already imagined something like that.
What I wanted to do, was setting an away message when I'm gone and removing it when I'm back.
I'm about to make my own wrapping now like this

sub OnLooseFocus()
if (world.GetVariable("FocusAway")=0) then
world.send "away He's doing something else"
end if
world.setvariable "FocusAway",1
end sub

sub OnGetFocus()
if (world.GetVariable("FocusAway")=1) then
world.send "away"
end if
world.setvariable "FocusAway",0
end sub

In fact, I think I'll additionally use a one-shot timer in OnLooseFocus so that the away message will only be set if the world looses focus for more than a minute or so--just to avoid lot's of commands when I'm just checking for mail for a couple of seconds or so.
Thanks anayway,

Hagen