Skip to content

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".

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

true, or false, reason - the reason as a person reads it

-- F5 opens the menu and gives it the keyboard and the mouse; the call is made inside the key press, so the keyboard is granted
function OnKey(key, pressed)
if key == "f5" and pressed then
ShowWebFrame("menu")
SetWebFocus("menu", true, true)
end
end

IsWebFocused · SetWebFocusKeepInput · ShowWebFrame · HideWebFrame · the Web interface group of the index