hi, i just download the latest version from git hub and i got in my code this linker error:
 
unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > tgui::EditBox::Validator::Int" (?Int@Validator@EditBox@tgui@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
1>

if i choose the other way (well , i do not quite understand the two pair of brackets) it is working.

   pEditBoxServerPort->setInputValidator(tgui::EditBox::Validator::Int); -->linker error
   pEditBoxServerPort->setInputValidator("[0-9]*");->working as expected (only numbers)

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
I forgot to mark the validators to be exported in windows dlls. Latest github version should work now.

The square brackets define a set of valid inputs, so "[0-9]" means any character with ascii code between '0' and '9' (thus all numbers), "[a-zA-Z]" would mean all letters.

Edit: build on windows failed, I must have still done something wrong

ok, but can u explain your example code in header file (EditBox.hpp)

"[a-zA-Z][a-zA-Z0-9]*" what the second pair of brackets mean?

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
The first part "[a-zA-Z]" matches with any letter, the second part "[a-zA-Z0-9]" matches with any letter or number. The "*" means that the second part can occur 0 or multiple times. So this matches any string that has letters and numbers but has no number as first character. Technically an empty string is not valid, but the editbox always accepts an empty string.
It isn't really practical, it just shows what you can do with the function.

The windows build is fine now, so you can download the latest version and build it to be able to use EditBox::Validator::Int.
At moments like these I am glad to have a CI set up for multiple operating systems so that I know relatively fast that I screwed up with a change.

Thanks for the explanation and the fixes.


Found a issue that i can track it down.

In my edit box i have set    setInputValidator("[0-9]*\\,\\.?[0-9]*"). All i want is any numeric value with commas or dots. "example 1=230,450" , "example 2= 100.21"

The problem is that if the edit box has no text then i can not edit nothing but commas or dots for start letter. Is anything wrong with my value string into inputvalidator function?

thanks

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
The regex is wrong. I don't think you need the backslashes in front of the comma (only in front of the dot because a dot has a special meaning). But your regex requires your text to have a comma and optionally a dot inside it. So the string ",." is also valid. You can use | as an OR so the regex can be: "[0-9]*(,|\\.)?[0-9]*". It will match either a comma or a dot or neither (due to the question mark) but not both. Alternatively you can also use "[0-9]*[,.]?[0-9]*" which is slightly shorter.

And I just read that you can match digits with \d, so you can even write it as "\\d*[,.]?\\d*". More information about the syntax can be found here.

Yes that it is exactly what i needed. It is a great convenience this function. And the syntax allow you to do anything you like.