itHyperoX Posted April 2, 2018 Share Posted April 2, 2018 (edited) Hi, i found this dxlib on the community, i'm working on a weapon shop, when i destroy the dxEditBox, then i reopen, i'm only getting erros. I tried to fix it myself, and i still don't know whats the problem. Debugs: line 19: onClientKey with this function is already handled line 20: onClientCharacter with this function is already handled. Code: function dxCreateEdit(x, y, w, h, text, icon, lenght, r, g, b, alpha, mask, postGUI) local theEdit = createElement("dxEdit") if getn(edit.data) < 1 then addEventHandler("onClientCharacter", getRootElement(), addCharacterToEdit) -- line 19 addEventHandler("onClientKey", root, backspace) -- line 20 end edit.data[theEdit] = {x = x, y = y ,w = w, h = h, dt = text, icon = icon, ml = lenght, r = r or 0, g = g or 0,b = b or 0, alpha = alpha or 150, mask = mask or false, postGUI = postGUI or false, text = "" , clicked = false, selectAll = false, enabled = true} return theEdit end function addCharacterToEdit(character) if character == " " then return end if string.byte(character) < 32 or string.byte(character) > 127 then return end local Edit = getElementsByType("dxEdit") for i=1,#Edit do if edit.data[Edit[i]] then if edit.data[Edit[i]].clicked == true then if edit.data[Edit[i]].selectAll == true then edit.data[Edit[i]].selectAll = false edit.data[Edit[i]].text = "" end if edit.data[Edit[i]].ml ~= nil then if #edit.data[Edit[i]].text < edit.data[Edit[i]].ml then edit.data[Edit[i]].text = edit.data[Edit[i]].text..character end else edit.data[Edit[i]].text = edit.data[Edit[i]].text..character end end end end end function backspace(key,sm) if sm then local Edit = getElementsByType("dxEdit") for i=1,#Edit do if edit.data[Edit[i]] then if edit.data[Edit[i]].clicked == true then if string.len(edit.data[Edit[i]].text) > 0 and key == "backspace" then if edit.data[Edit[i]].selectAll == false then edit.data[Edit[i]].text = string.sub(edit.data[Edit[i]].text,1,string.len(edit.data[Edit[i]].text)-1) else edit.data[Edit[i]].selectAll = false edit.data[Edit[i]].text = "" end elseif getKeyState("lctrl") and key == "a" or getKeyState("rctrl") and key == "a" then edit.data[Edit[i]].selectAll = not edit.data[Edit[i]].selectAll end end end end end end Edited April 2, 2018 by TheMOG Link to comment
Moderators Patrick Posted April 3, 2018 Moderators Share Posted April 3, 2018 (edited) function dxCreateEdit(x, y, w, h, text, icon, lenght, r, g, b, alpha, mask, postGUI) local theEdit = createElement("dxEdit") if getn(edit.data) < 1 then removeEventHandler("onClientCharacter", getRootElement(), addCharacterToEdit) -- line 19 removeEventHandler("onClientKey", root, backspace) -- line 20 addEventHandler("onClientCharacter", getRootElement(), addCharacterToEdit) -- line 19 addEventHandler("onClientKey", root, backspace) -- line 20 end edit.data[theEdit] = {x = x, y = y ,w = w, h = h, dt = text, icon = icon, ml = lenght, r = r or 0, g = g or 0,b = b or 0, alpha = alpha or 150, mask = mask or false, postGUI = postGUI or false, text = "" , clicked = false, selectAll = false, enabled = true} return theEdit end Edited April 3, 2018 by gpetersz 1 Link to comment
itHyperoX Posted April 3, 2018 Author Share Posted April 3, 2018 (edited) Right, now i don't get any error, but now sometimes the cursor is not hiding. Fixed, thanks. Edited April 3, 2018 by TheMOG Link to comment
Scripting Moderators thisdp Posted April 10, 2018 Scripting Moderators Share Posted April 10, 2018 But why not use my dx lib? 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now