SetWebFocus
Gives a frame the keyboard and the mouse cursor, or takes them back.
A frame that has the cursor gets the mouse: the player can click in its page. A frame that has the keyboard gets
the keys: typed letters go to the page’s text fields and the game does not see them. With neither keyboard nor cursor
the frame gives its focus up. SetWebFocusKeepInput lets the game keep the player’s keys meanwhile.
The frame’s focus setting in ui.toml decides what a request gets - a script cannot take the player’s keyboard behind
their back: "never" refuses every request; "input" (the default) grants the cursor at once and the keyboard only
within five seconds of the player’s own click or key press in that frame, or when the call is made inside
OnKey, the player’s own key press; "open" grants the cursor at any time and the keyboard after the player’s first
click in the frame since it was shown. A frame that is hidden takes no focus.
Returns true when the request was handed over - not that the frame got the focus: ask IsWebFocused a moment
later. false and the reason when it could not be handed over: "no web layer", "no web interface" or
"no such frame".
Syntax
Section titled “Syntax”SetWebFocus(frame, keyboard, cursor)| Parameter | Type | |
|---|---|---|
frame |
string | the frame’s name |
keyboard |
boolean | true to give the frame the keyboard |
cursor |
boolean | true to give the frame the mouse cursor |
Returns
Section titled “Returns”true, or false, reason - the reason as a person reads it
Example
Section titled “Example”-- F5 opens the menu and gives it the keyboard and the mouse; the call is made inside the key press, so the keyboard is grantedfunction OnKey(key, pressed) if key == "f5" and pressed then ShowWebFrame("menu") SetWebFocus("menu", true, true) endendSee also
Section titled “See also”IsWebFocused · SetWebFocusKeepInput · ShowWebFrame · HideWebFrame · the Web interface group of the index
