Editbox -> Just no.?!

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

fame
Just popping in
Just popping in
Posts: 3
Joined: Wed Oct 15, 2008 21:36
Contact:

Editbox -> Just no.?!

Postby fame » Wed Jan 28, 2009 14:17

Hi,

how can i get the editbox to only accept no. like "23.1282"?

Is that the validation string? I didnt get that worked, could you help me?

Thanks! :)

Regards,
fame

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jan 28, 2009 14:56

Hi,

You are correct that the validation string can be used to limit acceptable input to the editbox. The validation string is a regular expression that the editbox text string must match in order to be 'valid', and any input that would cause the string to become invalid is rejected.

This throws up key point, that the regular expression must match at all times, sometimes this means a slightly more complex regex than might otherwise have been needed.

Anyway, to limit the text to digits, with an optional decimal point - which must be preceded by at least one digit (i.e. a useful number limiting regex) would look something like this:

Code: Select all

"\d*?(\d+\.)?\d*"


Dont forget that if you put that in a C++ string literal, you have to escape the backslashes, so:

Code: Select all

"\\d*?(\\d+\\.)?\\d*"


HTH

CE.

fame
Just popping in
Just popping in
Posts: 3
Joined: Wed Oct 15, 2008 21:36
Contact:

Postby fame » Wed Jan 28, 2009 15:57

Thanks a lot!

The problem was i chosed the wrong regexp. Thats definitly a thing i should learn!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 8 guests