Input Validation

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Blackroot
Just popping in
Just popping in
Posts: 7
Joined: Tue Dec 27, 2016 16:20

Input Validation

Postby Blackroot » Wed May 10, 2017 11:20

Hi guys, real quick bug I seem to have stumbled upon.

There's an issue when setting input validation on edit boxes, possibly on other items. Ex:

Code: Select all

            <Window type="GlossySerpentFHD/Editbox" name="colorValue" >
                <Property name="Area" value="{{0,0},{0,50},{0,245},{0,100}}" />
                <Property name="Text" value="111,111,111" />
                <Property name="ValidationString" value="^[0-2][0-5][0-5],[0-2][0-5][0-5],[0-2][0-5][0-5]$" />
            </Window>
           


This window will not take input. Not valid or otherwise, it simply refuses. If I return the input validation string to wildcard everything works fine. Strange bug, seems to make the input validation rather useless at the moment.

I poked around the code a bit, CEGUI uses PCRE regex format, you can verify your regex patterns here:
https://regex101.com/

At first I had some datafill automatically input into the editbox, I figured maybe CEGUI was ignoring my DEL key or something. This doesn't seem to be the case, so I dug around a bit more.

Code: Select all

class CEGUIEXPORT Editbox : public Window
<protected>
    bool handleValidityChangeForString(const String& str);
   


This seems like the disconnect point between user input and the PCRE matching. Input doesn't appear to be discarded, something is wrong between validating and updating the change which appears to start at the aforementioned function.

Thanks guys!

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Input Validation

Postby Ident » Wed May 10, 2017 16:00

CEGUI version?

Did you try out a simpler ValidationString ? We have input validation in one of the examples and it works fine there. I am not sure I 100% understand the problem - like can you not get any validation to work or did you only try this one or what?

And you are right: we use the pcre library, but it might be that the library uses slightly different formats than the standard itself? Not sure about thta last one.
CrazyEddie: "I don't like GUIs"

Blackroot
Just popping in
Just popping in
Posts: 7
Joined: Tue Dec 27, 2016 16:20

Re: Input Validation

Postby Blackroot » Wed May 10, 2017 21:04

Ident wrote:CEGUI version?

Did you try out a simpler ValidationString ? We have input validation in one of the examples and it works fine there. I am not sure I 100% understand the problem - like can you not get any validation to work or did you only try this one or what?

And you are right: we use the pcre library, but it might be that the library uses slightly different formats than the standard itself? Not sure about thta last one.


Version 8.7

Okay, I've played around with the regex a fair bit.

Code: Select all

[a-zA-Z] works, I should note it ignores the DEL key
[a-z] works, also ignores DEL
[0-9] works, ignores DEL also
[0-9][a-z] takes no input.
^[0-9][a-z]$ same as above
[0-9] (Unicode 32 backspace character) crashes.


I tried a couple of other things, the jist appears to be that CEGUI will take literally only the input characters and will only accept regex expressions with at most one block of terms. I'll try and hunt down where CEGUI is interfacing with PCRE and see whats going on.

Thanks for the help!

[[

I should note my implementation for injecting text input to CEGUI is via SDL, although it seems like characters are being input fine the unicode crash worries me a bit.

Code: Select all

         case SDL_TEXTINPUT:
            //Handles unicoderino
            auto cs = CEGUI::String((CEGUI::utf8*) evnt.text.text);
            for (int i = 0; i < cs.size(); ++i) {
               context->injectChar(cs[i]);
            }


]]

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Input Validation

Postby Ident » Thu May 11, 2017 07:15

Which String version did you select for CEGUI when configuring CEGUI in Cmake?

the unicode crash worries me a bit.

What crash? You never mention it explicitly.

ignores DEL

You mean if you hit delete it won't delete anything? That's odd.


I used quite complex regex expressions in the past in 0.8.X and afaik we did not do any changes in regards to validation. I also remember delete working fine.


Btw does [0-9a-zA-Z] just work fine?
CrazyEddie: "I don't like GUIs"


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests