OnClientGUIFocus: Difference between revisions
Jump to navigation
Jump to search
m (→Parameters) |
Fernando187 (talk | contribs) m (formatting) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This event is triggered each time a GUI element gains input focus (mainly useful for windows, editboxes and memos but triggered for all GUI elements nevertheless). | This event is triggered each time a GUI element gains input focus (mainly useful for windows, editboxes and memos but triggered for all GUI elements nevertheless). | ||
{{Note|When a widget in a window that didn't have focus before receives focus, ''onClientGUIFocus'' is triggered first for the window and then for the child widget. | |||
When the window already had focus, ''onClientGUIFocus'' is only triggered for the newly focused child widget.}} | |||
==Parameters== | ==Parameters== | ||
| Line 41: | Line 44: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_events}} | {{GUI_events}} | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} | ||
Latest revision as of 17:49, 1 June 2025
This event is triggered each time a GUI element gains input focus (mainly useful for windows, editboxes and memos but triggered for all GUI elements nevertheless).
Parameters
No parameters.
Source
The source of this event is the GUI element which just gained input focus.
Example
local window, editbox = nil, nil
addCommandHandler("example",
function()
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 263, 90
local left = screenWidth/2 - windowWidth/2
local top = screenHeight/2 - windowHeight/2
window = guiCreateWindow(left, top, windowWidth, windowHeight, "Example Window", false)
editbox = guiCreateEdit(11, 41, 241, 22, "", false, window)
addEventHandler("onClientGUIFocus", editbox, onClientGUIFocus_editbox, true) --true because for the example we want propagated events
addEventHandler("onClientGUIBlur", editbox, onClientGUIBlur_editbox, true) --true because for the example we want propagated events
showCursor(true)
end)
function onClientGUIFocus_editbox()
if source == editbox then
outputChatBox("Example editBox received input focus")
elseif source == window then
outputChatBox("Example window received input focus")
end
end
function onClientGUIBlur_editbox()
if source == editbox then
outputChatBox("Example editBox lost input focus")
elseif source == window then
outputChatBox("Example window lost input focus")
end
end
See Also
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled