Here is an example of wxTextValidator usage.
\begin{verbatim}
- wxTextCtrl *txt1 = new wxTextCtrl(this, VALIDATE_TEXT, "",
+ wxTextCtrl *txt1 = new wxTextCtrl(this, -1, wxT(""),
wxPoint(10, 10), wxSize(100, 80), 0,
wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
\end{verbatim}
You can optionally define event handlers for the validator, to implement filtering. These handlers
will capture events before the control itself does.
-For an example implementation, see the valtext.h and valtext.cpp files in the wxWindows library.
+For an example implementation, see the valtext.h and valtext.cpp files in the wxWidgets library.
\wxheading{How validators interact with dialogs}
\begin{verbatim}
void wxDialog::OnOK(wxCommandEvent& event)
{
- if ( Validate() && TransferDataFromWindow() )
- {
+ if ( Validate() && TransferDataFromWindow() )
+ {
if ( IsModal() )
EndModal(wxID_OK);
else
{
- SetReturnCode(wxID_OK);
- this->Show(false);
+ SetReturnCode(wxID_OK);
+ this->Show(false);
}
- }
+ }
}
\end{verbatim}