OnDgsBlur: Difference between revisions
m (Thisdp moved page Dgs/onClientDgsDxBlur to OnClientDgsDxBlur) |
No edit summary |
||
Line 1: | Line 1: | ||
local window, editbox = nil, nil | local window, editbox = nil, nil | ||
DGS = exports.dgs | DGS = exports.dgs | ||
Line 19: | Line 7: | ||
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 22: | ||
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 41: | Line 29: | ||
end | end | ||
end | end | ||
Revision as of 13:36, 20 January 2018
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