OnDgsBlur: Difference between revisions
Jump to navigation
Jump to search
(→Notes) |
m (Thisdp moved page OnClientDgsDxBlur to OnDgsBlur) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
local left = screenWidth/2 - windowWidth/2 | local left = screenWidth/2 - windowWidth/2 | ||
local top = screenHeight/2 - windowHeight/2 | local top = screenHeight/2 - windowHeight/2 | ||
window = DGS: | window = DGS:dgsCreateWindow(left, top, windowWidth, windowHeight, "Example Window", false) | ||
editbox = DGS: | editbox = DGS:dgsCreateEdit(11, 41, 241, 22, "", false, window) | ||
addEventHandler(" | addEventHandler("onDgsFocus", editbox, onDGSFocus_editbox, true) --true because for the example we want propagated events | ||
addEventHandler(" | addEventHandler("onDgsBlur", editbox, onDGSBlur_editbox, true) --true because for the example we want propagated events | ||
showCursor(true) | showCursor(true) | ||
end) | end) | ||
function | function onDGSFocus_editbox() | ||
if source == editbox then | if source == editbox then | ||
outputChatBox("Example editBox received input focus") | outputChatBox("Example editBox received input focus") | ||
Line 34: | Line 34: | ||
end | end | ||
function | function onDGSBlur_editbox() | ||
if source == editbox then | if source == editbox then | ||
outputChatBox("Example editBox lost input focus") | outputChatBox("Example editBox lost input focus") | ||
Line 44: | Line 44: | ||
==Notes== | ==Notes== | ||
*When the focus is transfered from one DGS element to an other, it is guaranteed that '' | *When the focus is transfered from one DGS element to an other, it is guaranteed that ''onDgsBlur'' on the element that lost focus is triggered before [[onDgsBlur|onDgsBlur]] on the element that just gained focus | ||
*When the focus of a full window is lost (transfered to an other window or lost), '' | *When the focus of a full window is lost (transfered to an other window or lost), ''onDgsBlur'' is only triggered for the window itself even if one of its widgets had focus too. It's important in this case to use the 4th parameter of [[addEventHandler]] if you are only registered for the events of a child widget (cf. Example) | ||
*When a window is hidden with [[ | *When a window is hidden with [[DgsSetVisible|dgsSetVisible]], it (or its child widget having focus) keeps focus internally until an other window gains focus or the chatbox is used | ||
==See Also== | ==See Also== |
Latest revision as of 13:39, 20 January 2018
This event is triggered each time a DGS element looses input focus (mainly useful for windows, editboxes and memos but triggered for all DGS elements nevertheless).
Parameters
None
Source
The source of this event is the DGS element which just lost input focus.
Example
local window, editbox = nil, nil DGS = exports.dgs 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 = DGS:dgsCreateWindow(left, top, windowWidth, windowHeight, "Example Window", false) editbox = DGS:dgsCreateEdit(11, 41, 241, 22, "", false, window) addEventHandler("onDgsFocus", editbox, onDGSFocus_editbox, true) --true because for the example we want propagated events addEventHandler("onDgsBlur", editbox, onDGSBlur_editbox, true) --true because for the example we want propagated events showCursor(true) end) function onDGSFocus_editbox() if source == editbox then outputChatBox("Example editBox received input focus") elseif source == window then outputChatBox("Example window received input focus") end end function onDGSBlur_editbox() if source == editbox then outputChatBox("Example editBox lost input focus") elseif source == window then outputChatBox("Example window lost input focus") end end
Notes
- When the focus is transfered from one DGS element to an other, it is guaranteed that onDgsBlur on the element that lost focus is triggered before onDgsBlur on the element that just gained focus
- When the focus of a full window is lost (transfered to an other window or lost), onDgsBlur is only triggered for the window itself even if one of its widgets had focus too. It's important in this case to use the 4th parameter of addEventHandler if you are only registered for the events of a child widget (cf. Example)
- When a window is hidden with dgsSetVisible, it (or its child widget having focus) keeps focus internally until an other window gains focus or the chatbox is used
See Also
DGS events
General
- onDgsBlur
- onDgsCreate
- onDgsCursorTypeChange
- onDgsCursorStateChange
- onDgsDestroy
- onDgsElementRender
- onDgsElementMove
- onDgsElementSize
- onDgsElementEnter
- onDgsElementLeave
- onDgsFocus
- onDgsKey
- onDgsPositionChange
- onDgsPreRender
- onDgsRender
- onDgsElementScroll
- onDgsSizeChange
- onDgsTextChange
- onDgsWindowClose
- onDgsPropertyChange
Check Box
Combo Box
Drag'N Drop
Edit
Grid List
Menu
Selector
Mouse
- onDgsMousePreClick
- onDgsMouseClick
- onDgsMouseClickDown
- onDgsMouseClickUp
- onDgsMouseDrag
- onDgsMouseDoubleClick
- onDgsMouseDoubleClickDown
- onDgsMouseDoubleClickUp
- onDgsMouseDown
- onDgsMouseHover
- onDgsMouseEnter
- onDgsMouseLeave
- onDgsMouseMultiClick
- onDgsMouseMove
- onDgsMouseStay
- onDgsMouseUp
- onDgsMouseWheel
Radio Button
Switch Button
Tab
Animation
Plugin
Media
- onDgsMediaPlay
- onDgsMediaPause
- onDgsMediaStop
- onDgsMediaLoaded
- onDgsMediaTimeUpdate
- onDgsMediaBrowserReturn
Color Picker
QRCode
Remote Image
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled