ID:2104976
 
(See the best response by Nadrew.)
I made a verb that toggles whether my game's input control has focus or not.
The player presses the Tab key to toggle focus on or off. Toggling focus on lets them type in the input, toggling it off puts focus back to the map so they can use verb macros normally.

Toggling focus on to the input works. But then pressing Tab again doesn't take focus off. It just continues letting them type letters into the input instead of being able to use their verb macros.

mob/verb/MouseFocusToggle()
set hidden=1
world<<"called"

if(winget(usr,"outputwindow.input1","focus") == "true")
winset(usr,"outputwindow.input1","focus=false")
winset(usr,"mainwindow.map","focus=true")
world<<"true"

else
winset(usr,"mainwindow.map","focus=false")
winset(usr,"outputwindow.input1","focus=true")
world<<"false"

So why can't I take focus away from the input with this? Thanks
Best response
Is the verb being called at all when you have the input focused? I'm asking because there's quite a few keys that aren't intercepted as macros when an input has focus and I can't remember if tab is one of them. Outside of that the code looks like it should be functional at a glance.
I agree with Nadrew. You'll have to use a key that can't be typed, like Escape or F# keys.

Also, I don't think setting focus=false does anything. Focus changes when you set focus=true.
Yes I tested that, when I press the Tab key, even when the input control has focus (ie: lets me type in it, has a blinking cursor, etc), it says "called" when I press the Tab key.

It says "called" "true". Meaning both MouseFocusToggle was called, and winget() says the input currently has focus. And yet, focus is not taken away from the input control even though you see it says winset(usr,"outputwindow.input1","focus=false") right there in the code
As Kaiochao said, focus=false does nothing, so that line is wasted. (Incidentally, you don't need a verb for this at all; this can be done with a conditional client-side .winset.)

It may well be a problem using Tab due to the fact that Tab, Space, and Back are all treated specially in input controls.
In response to Lummox JR
Lummox JR wrote:
As Kaiochao said, focus=false does nothing, so that line is wasted. (Incidentally, you don't need a verb for this at all; this can be done with a conditional client-side .winset.)

It may well be a problem using Tab due to the fact that Tab, Space, and Back are all treated specially in input controls.

Cool. I don't know what a conditional client-side .winset is or looks like though
Conditional winsets are described in the skin reference under "Special .winset commands".