TGUI Forum

General Category => Help requests => Topic started by: ScorpionWasp on 23 November 2015, 16:08:53

Title: Limiting Type of Input Edit Box/Text Box Accepts
Post by: ScorpionWasp on 23 November 2015, 16:08:53
Hello there.

1 - I want my edit/text boxes to only accept integers, and ignore any other keystrokes. Is that functionality available?

2 - What's the difference between text/edit boxes? Maybe I'm using the wrong component here entirely... Is there any component that does what I want in question 1?
Title: Re: Limiting Type of Input Edit Box/Text Box Accepts
Post by: texus on 23 November 2015, 16:56:05
1) You can call editBox->setNumbersOnly() to disallow text in it, but there is currently no way to limit the edit box to integers only (e.g. the following can be written in a numbers only edit box: "-1.235e6"). There are a lot of different uses for limiting characters (some would want only positive integers, others would want floats but without the optional 'e' behind it, ...) and I have not yet found a way to provide a proper way to allow all these possibilities.

2) An edit box is a single line of text without newlines, a text box is a multi-lined text field.