SetWebFocus: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|Sets (keyboard) focus to a WebUI. Useful for custom chats. After calling this function you should also focus the HTML input el..." |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1. | {{Info|Function|Client|1.4.3}} | ||
{{FuncDescription|Sets (keyboard) focus to a WebUI. Useful for custom chats. | {{FuncDescription|Sets (keyboard) focus to a WebUI. Useful for custom chats. | ||
Line 15: | Line 15: | ||
== Example == | == Example == | ||
<syntaxhighlight lang='Lua'> | <syntaxhighlight lang='Lua'> | ||
function OnKeyPress(key) | |||
if key == "Space Bar" then | if key == "Space Bar" then | ||
if IsCtrlPressed() then | if IsCtrlPressed() then | ||
Line 22: | Line 23: | ||
end | end | ||
end | end | ||
end | |||
AddEvent("OnKeyPress", OnKeyPress) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:WebFunctions}} | {{Template:WebFunctions}} |
Latest revision as of 17:38, 11 February 2021
Description
Sets (keyboard) focus to a WebUI. Useful for custom chats.
After calling this function you should also focus the HTML input element in javascript. https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus
Syntax
SetWebFocus(web)
Parameters
- web
The web identifier
Return Value
- This function returns true on success.
Example
function OnKeyPress(key)
if key == "Space Bar" then
if IsCtrlPressed() then
AddPlayerChat("Focus mapeditor")
SetWebFocus(EditorGui)
ExecuteWebJS(EditorGui, "FocusInput();")
end
end
end
AddEvent("OnKeyPress", OnKeyPress)