Hi guys!
This is my firts project with CEGUI and I've got a problem which seems to be very simple, but for me it's impossible to solve it. All I need to do is an editbox for numbers only.
I tried 2 ways. First was of course Spinner, but the problem was that I could change the number only by the arrows (not by writing it in the box). I got similar result with the second way - ValidationString and RegEx. This time it was impossible to change the text at all.
I also tried to find any topic which covered this problem but I found none.
So if you could please give me at least some hint...
Thanks in advance
Must Ill
Editbox for numbers only
Moderators: CEGUI MVP, CEGUI Team
Thanks Van, but I already know that (as I wrote above), but the problem is that when I set the validation string the user cannot write in the editbox.
Here's what I used as validation string:
"[3-5][0-9]{4}"
As far as I know RegExes this should allow the user to enter numbers between 30000 and 59999 (and that's what I need
). I think that probably the problem is that the validation string must stand all the time, so if the editbox is empty at the beginning it would oppose the val. string each time a key is pressed.
"/d*"
I hope (
) this should mean "string made only of digits with any length". If at least this could work I would be able to check whether the number is in the range I want it to be by myself later (for example when the "Start Game" button is pressed). But the problem with not beaing able to write in remains.
".*"
Well, this is the only RegEx I got to work, but for me it's useless
Please, if you've got experience with this give me a hint...
Thanks in advance
Must Ill
Here's what I used as validation string:
"[3-5][0-9]{4}"
As far as I know RegExes this should allow the user to enter numbers between 30000 and 59999 (and that's what I need

"/d*"
I hope (

".*"
Well, this is the only RegEx I got to work, but for me it's useless

Please, if you've got experience with this give me a hint...
Thanks in advance
Must Ill
Have a look at the code within [http://www.cegui.org.uk/wiki/index.php/Formatted_Numeric_Data]Formatted_Numeric_Data[/url], more precisely the spinner control's onSpinnerValueChanged() within the FormattedData class. I'm basically converting a numeric value into a different display string; the internal value of the object is "validated" and then a formatted string is being displayed.
Using this approach you could validate the value of the editbox yourself and if valid then display that value/digit otherwise remove that digit.
Using this approach you could validate the value of the editbox yourself and if valid then display that value/digit otherwise remove that digit.
Who is online
Users browsing this forum: No registered users and 21 guests