Loading...
Searching...
No Matches
juce::TextEditor::LengthAndCharacterRestriction Class Reference

Detailed Description

An input filter for a TextEditor that limits the length of text and/or the characters that it may contain.

Inheritance diagram for juce::TextEditor::LengthAndCharacterRestriction:

Public Member Functions

 LengthAndCharacterRestriction (int maxNumChars, const String &allowedCharacters)
 Creates a filter that limits the length of text, and/or the characters that it can contain.
String filterNewText (TextEditor &, const String &) override
 This method is called whenever text is entered into the editor.
Public Member Functions inherited from juce::TextEditor::InputFilter
 InputFilter ()=default
virtual ~InputFilter ()=default

Constructors and Destructors

◆ LengthAndCharacterRestriction()

juce::TextEditor::LengthAndCharacterRestriction::LengthAndCharacterRestriction ( int maxNumChars,
const String & allowedCharacters )

Creates a filter that limits the length of text, and/or the characters that it can contain.

Parameters
maxNumCharsif this is > 0, it sets a maximum length limit; if <= 0, no limit is set
allowedCharactersif this is non-empty, then only characters that occur in this string are allowed to be entered into the editor.

Referenced by filterNewText().

Member Functions

◆ filterNewText()

String juce::TextEditor::LengthAndCharacterRestriction::filterNewText ( TextEditor & ,
const String & newInput )
overridevirtual

This method is called whenever text is entered into the editor.

An implementation of this class should check the input string, and return an edited version of it that should be used.

Implements juce::TextEditor::InputFilter.

References LengthAndCharacterRestriction(), and juce::TextEditor::TextEditor().

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram