titan_boy Posted May 22, 2015 Share Posted May 22, 2015 Hello, I have found a bug in a script of me and i can fix it with disabling pasing in a editbox. Does anyone know how to do that? Link to comment
AriosJentu Posted May 23, 2015 Share Posted May 23, 2015 local UseText = edit:getText() addEventHandler("onClientGUIChanged", root, function() if source ~= edit then return false end edit:setText(UseText) end) To set text, use that UseText = text edit:setText(UseText) Link to comment
titan_boy Posted May 23, 2015 Author Share Posted May 23, 2015 thank you i will try it! Link to comment
Anubhav Posted May 24, 2015 Share Posted May 24, 2015 guiSetEnabled This is your answer. Link to comment
Walid Posted May 24, 2015 Share Posted May 24, 2015 guiSetEnabledThis is your answer. this function it only enable/disable the GUI element and he is asking about How to disable pasting in a edit box. Link to comment
Mr.unpredictable. Posted May 24, 2015 Share Posted May 24, 2015 guiSetEnabledThis is your answer. Wow, Never knew guiSetEnabled can disable pasting in edit box lol Link to comment
Anubhav Posted May 24, 2015 Share Posted May 24, 2015 What is wrong? It's the same as AriosJentu. His code disable writing in a edit box. It won't let you paste nor write. But I think he means write. let's see Link to comment
titan_boy Posted May 24, 2015 Author Share Posted May 24, 2015 its not working i tryd this: local UseText = guiGetText(add_item_price) addEventHandler("onClientGUIChanged", add_item_price, function() if source ~= edit then return false end guiSetText(add_item_price, UseText) end) Link to comment
Anubhav Posted May 25, 2015 Share Posted May 25, 2015 local UseText = guiGetText(add_item_price) addEventHandler("onClientGUIChanged", add_item_price, function() if source ~= add_item_price then return false end guiSetText(add_item_price, UseText) end) Link to comment
xXMADEXx Posted May 25, 2015 Share Posted May 25, 2015 I don't think any of those codes are what he is looking for. He wants it so that you can still edit in a text box, but just can't paste in it. This can be achieved by comparing the lengths of the text box with the old text and the new text. I have tested this code, and it seemed to be working just fine. local textBox = guiCreateEdit ( 100, 100, 200, 40, "Some Sample Text", false ); addEventHandler ( "onClientGUIChanged", textBox, function ( ) local oldText = getElementData ( source, "guiEdit:oldTextString" ); local text = guiGetText ( source ); if ( not oldText ) then setElementData ( source, "guiEdit:oldTextString", text ) return false; end if ( string.len ( text ) > string.len ( oldText ) ) then if ( string.len ( text ) - string.len ( oldText ) > 1 ) then guiSetText ( source, oldText ); outputChatBox ( "Pasting is not allowed!" ); return end end setElementData ( source, "guiEdit:oldTextString", text ); end ); 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