## wxTextValidator

wxTextValidator validates text controls, providing a variety of filtering behaviours.

For more information, please see Validator overview.

Derived from

wxValidator
wxEvtHandler
wxObject

Include files

<wx/valtext.h>

See also

Validator overview, wxValidator, wxGenericValidator

Members

wxTextValidator::wxTextValidator
wxTextValidator::~wxTextValidator
wxTextValidator::Clone
wxTextValidator::GetExcludeList
wxTextValidator::GetIncludeList
wxTextValidator::GetStyle
wxTextValidator::OnChar
wxTextValidator::SetExcludeList
wxTextValidator::SetIncludeList
wxTextValidator::SetStyle
wxTextValidator::TransferFromWindow
wxTextValidator::TransferToWindow
wxTextValidator::Validate

### wxTextValidator::wxTextValidator

wxTextValidator(const wxTextValidator& validator)

Copy constructor.

wxTextValidator(long style = wxFILTER_NONE, wxString* valPtr = NULL)

Constructor, taking a style and optional pointer to a wxString variable.

Parameters

style

A bitlist of flags, which can be:

wxFILTER_NONE | No filtering takes place.
wxFILTER_ASCII | Non-ASCII characters are filtered out.
wxFILTER_ALPHA | Non-alpha characters are filtered out.
wxFILTER_ALPHANUMERIC | Non-alphanumeric characters are filtered out.
wxFILTER_NUMERIC | Non-numeric characters are filtered out.
wxFILTER_INCLUDE_LIST | Use an include list. The validator checks if the user input is on the list, complaining if not.
wxFILTER_EXCLUDE_LIST | Use an exclude list. The validator checks if the user input is on the list, complaining if it is.
wxFILTER_INCLUDE_CHAR_LIST | Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if not.
wxFILTER_EXCLUDE_CHAR_LIST | Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if it is.

valPtr

A pointer to a wxString variable that contains the value. This variable should have a lifetime equal to or longer than the validator lifetime (which is usually determined by the lifetime of the window).

### wxTextValidator::~wxTextValidator

~wxTextValidator()

Destructor.

### wxTextValidator::Clone

virtual wxValidator* Clone() const

Clones the text validator using the copy constructor.

### wxTextValidator::GetExcludeList

wxStringList& GetExcludeList() const

Returns a reference to the exclude list (the list of invalid values).

### wxTextValidator::GetIncludeList

wxStringList& GetIncludeList() const

Returns a reference to the include list (the list of valid values).

### wxTextValidator::GetStyle

long GetStyle() const

Returns the validator style.

### wxTextValidator::OnChar

void OnChar(wxKeyEvent& event)

Receives character input from the window and filters it according to the current validator style.

### wxTextValidator::SetExcludeList

void SetExcludeList(const wxStringList& stringList)

Sets the exclude list (invalid values for the user input).

### wxTextValidator::SetIncludeList

void SetIncludeList(const wxStringList& stringList)

Sets the include list (valid values for the user input).

### wxTextValidator::SetStyle

void SetStyle(long style)

Sets the validator style.

### wxTextValidator::TransferFromWindow

virtual bool TransferFromWindow()

Transfers the string value to the window.

### wxTextValidator::TransferToWindow

virtual bool TransferToWindow()

Transfers the window value to the string.

### wxTextValidator::Validate

virtual bool Validate(wxWindow* parent)

Validates the window contents against the include or exclude lists, depending on the validator style.