I had been searching the forums for this topic and saw that some people had similar questions, but I didn't find a whole lot about how to implement it.

My problem was when creating an editbox window, I wanted to limit the characters being entered and specifically I wanted only numeric values in the range of 0-359. Here's how I was able to do it after reading up on regular expression syntax.

First it has been explained that you can limit what kind of input is acceptable in the editbox via the setValidationString function. The string this takes in is based on regular expression or regex. You can do a google search on regex and see all the nifty things that can be done with it.

Now here is how I solved my specific problem, only numbers 0 - 359.

"(3[0-5][0-9]|[0-2]?[0-9]?[0-9]?)"

Pass that into setValidationString() and you'll get the proper results.

I hope this helps someone save some time. I'm sure that you can do the research on your own and figure it out, but that's what I've come up with. Now all I need to know is why the number pad doesn't seem to inject input. Anyone know a solution for that?

For negative numbers, here's what I pieced together. If the range is the same on both sides, eg -128 to 128, then you just need an optional - sign (marked by the ? postfix). In this situation, you are telling Regex that the "-" is allowed, but not required.

If the range is not even, like -30 to 40, you'll have to make conditional statements for both sides of zero. The negative range needs to come first in the statement, and the negative sign non-optional. In this situation, you are telling Regex that for statements starting with "-", this is the ranges allowed.

If you don't put the negative statements first, you won't be able to add a negative sign into the editbox. The Regex checks from left to right, and it would fail you on the [0-2]?[0-9]?, since the two ? marks both character slots as optional, but neither accepts a "-". It won't check any further.

To clarify what JMiller wrote (we worked together on figuring this out), there are some necessary parts you need to add to your statements. He described a range of 0-359. Note that the " | " is an OR operator, like in C++.

The trick to this is creating the multiple ranges that will make up the whole range. The first statement allows the range between 300-359. This needs to come first in the case "3" is the first character, the Regex will match the following characters with it first. It will block any input that would create a value over 359, eg 371, the "1" won't get inputted.

The next statements allows for 0-299, filling out the range. However, each character is postfix with the ?. This makes both character slot optional. This is necessary because now it allows for a blank editbox, too. Otherwise, you'd have to highlight your text to change it.

Jmiller wrote:Now all I need to know is why the number pad doesn't seem to inject input. Anyone know a solution for that?

Not sure about this, are you sure your input system is generating character inputs in response to those key presses?

We looked into this and it's just a matter of how OIS deals with the keypad numbers it seems. None of the numbers were mapped to the font map (value of 0, so undefined basically). He got around it by manually mapping them in code. It had nothing to do with CEGUI.

Jmiller wrote:Now all I need to know is why the number pad doesn't seem to inject input. Anyone know a solution for that?

Not sure about this, are you sure your input system is generating character inputs in response to those key presses?

We looked into this and it's just a matter of how OIS deals with the keypad numbers it seems. None of the numbers were mapped to the font map (value of 0, so undefined basically). He got around it by manually mapping them in code. It had nothing to do with CEGUI.

I also want OIS keypad work for CEGUI input, but I still don't know how.
Anyone shed light on how to do this?