SetPlayerWebFocus
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. keepInput lets a frame hold the
keyboard without shutting the game’s out - the game still gets the player’s keys while no text field of the page has
the focus, so a player can walk with a panel open; it does nothing without keyboard. With neither keyboard nor
cursor the frame gives its focus up.
The frame’s focus setting in ui.toml decides what a request gets, so a server cannot grab a 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; "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. The
answer is true when the request was handed to the player’s game - whether the frame got the focus is decided there.
The answer is false and the reason when the request could not be handed over: "no such player",
"no web interface", "the player has no web layer" or "no such frame".
Syntax
Section titled “Syntax”SetPlayerWebFocus(pid, frame, keyboard, cursor [, keepInput])| Parameter | Type | |
|---|---|---|
pid |
number | the player |
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 |
keepInput |
boolean | true to let the game keep the player’s keys while the frame has the keyboard (optional) |
Returns
Section titled “Returns”true, or false, reason - the reason as a person reads it
Example
Section titled “Example”-- a login box: the cursor at once, the keyboard as soon as the player clicks into the password fieldfunction OnPlayerWebReady(pid, frame) if frame == "login" then SetPlayerWebFocus(pid, "login", true, true) endend
-- and back to the gamefunction OnClientEvent(pid, name, payload) if name == "login.done" then SetPlayerWebFocus(pid, "login", false, false) endendSee also
Section titled “See also”ShowPlayerWebFrame · HidePlayerWebFrame · the Web interface group of the index
