Thanks, that example works but.. I have another problem, when I click and try to type, the character appears in both edit field. How do I solve this?
addEventHandler("onClientRender", getRootElement(),
function()
panelLogin()
end
)
local font = {"title", "subtitle", "display", "button"}
...
font["display"] = dxCreateFont("file/ttf/roboto-regular.ttf", 9)
...
local word = {"username", "password"}
word["username"] = ""
word["password"] = ""
function panelLogin()
...
local display = {}
...
display[5] = dxDrawText(word["username"], 603, 366, 843, 382, tocolor(255, 255, 255, 255), 1.00, font["display"], "left", "center", false, false, false, false, false)
display[6] = dxDrawText(word["password"], 603, 392, 843, 408, tocolor(255, 255, 255, 255), 1.00, font["display"], "left", "center", false, false, false, false, false)
...
end
function isMouseInPosition(absoluteX, absoluteY, screenW, screenH)
if (not isCursorShowing()) then
return false
end
local screenX, screenY = guiGetScreenSize()
local cursorX, cursorY = getCursorPosition()
local cursorX, cursorY = (cursorX * screenX), (cursorY * screenY)
if (cursorX >= absoluteX and cursorX <= absoluteX + screenW) and (cursorY >= absoluteY and cursorY <= absoluteY + screenH) then
return true
else
return false
end
end
addEventHandler("onClientClick", getRootElement(),
function()
onClientClickEditPassword()
onClientClickEditUsername()
end
)
function onClientClickEditUsername()
if isMouseInPosition(603, 366, 240, 16) then
addEventHandler("onClientCharacter", getRootElement(), onClientEditUsername)
end
end
function onClientEditUsername(character)
word["username"] = word["username"]..character
end
function onClientClickEditPassword()
if isMouseInPosition(603, 366, 240, 16) then
addEventHandler("onClientCharacter", getRootElement(), onClientEditPassword)
end
end
function onClientEditPassword(character)
word["password"] = word["password"]..character
end
And by the way, how do I simplify the function? I think that my edit field will have a lot in my script and I don't want to repeat the script, there must be the way to make it own function, any help will be appreciate. Thank you for your time, may god bless your kindness and make you more genius!