Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Question regarding GuiTextEditCtrl (https://forums.graalonline.com/forums/showthread.php?t=134265557)

Gunderak 01-11-2012 04:42 AM

Question regarding GuiTextEditCtrl
 
Basically I am working on a trade system.
I want to make it so that if you enter a character that isn't a number it will remove it. I have made the detection weather it is a number or not but how would I remove the last character of the textedit control?
I have tried a few things, such as:
PHP Code:

Trade_MyGralats.text.length() -= 1;
Trade_MyGralats.text.size() -= 1;
Trade_MyGralats.text -= 1

But none of them work, Thanks in advanced.
I was also thinking maybe it would have something to do with .pos() Not sure though.
Maybe this is an idea for a future improvement for text controls.
PHP Code:

allowedcharactersonly true;
allowedcharacters= { "a""b""c" }; 


cbk1994 01-11-2012 05:07 AM

PHP Code:

Trade_MyGralats.text.length() -= 1;
Trade_MyGralats.text.size() -= 1

These make no sense, the return value of a function is not a variable.

PHP Code:

Trade_MyGralats.text -= 1

text is a string, not a number, so this isn't going to work either.

PHP Code:

Trade_MyGralats.text Trade_MyGralats.text.substring(0Trade_MyGralats.text.length() - 1); 

substring is the key. Probably you'd be better off just saving a copy of the old string (before letters were added) and then changing the text back to the old string if they enter a letter. Right now someone could just enter a letter anywhere but the end of the string and it wouldn't fix this.

Gunderak 01-11-2012 08:03 AM

Ahok. So when there is a keydown if they don't press a letter save temp.text, then if they press a letter change the text to temp.text, shoulda thought of that, thanks.

Mark Sir Link 01-11-2012 10:46 AM

the real solution though is to just have the guitexteditctrl use its own profile and change profile.numbersonly to true.

Gunderak 01-11-2012 11:16 AM

O_o That seems a lot simpler.
Does it allow to copy and paste though? Because I didn't want to allow copy and pasting.


All times are GMT +2. The time now is 11:58 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.