wxGenericValidator
generated from ../src/mod_gui/misc/genval.cpp
wxGenericValidator performs data transfer (but not validation or filtering)
for the following basic controls: wxButton, wxCheckBox, wxListBox,
wxStaticText, wxRadioButton, wxRadioBox, wxChoice, wxComboBox,
wxGauge, wxSlider, wxScrollBar, wxSpinButton, wxTextCtrl,
wxCheckListBox.
There's a difference between the wxWidgets implementation and the wxJS implementation:
wxWidgets automatically transfer the data to the given pointer variable when validation
succeeds. In JavaScript this is not possible. wxJS solves this with the
value property. This property returns the value of the control.
The type of this value is the same as the type of the argument of the constructor.
The following example shows how to use this class:
var user = "Demo";
var pwd = "";
function Application()
{
var dlg = new wxDialog(null, -1, "wxValidator Example",
wxDefaultPosition, new wxSize(200, 150));
var userText = new wxTextCtrl(dlg, -1);
var pwdText = new wxTextCtrl(dlg, -1);
var okButton = new wxButton(dlg, wxId.OK, "Ok");
var cancelButton = new wxButton(dlg, wxId.CANCEL, "Cancel");
dlg.sizer = new wxFlexGridSizer(4, 2, 10, 10);
dlg.sizer.add(new wxStaticText(dlg, -1, "Username"));
dlg.sizer.add(userText);
dlg.sizer.add(new wxStaticText(dlg, -1, "Password"));
dlg.sizer.add(pwdText);
dlg.sizer.add(okButton);
dlg.sizer.add(cancelButton);
// Create validator
var validator = new wxGenericValidator(user);
validator.validate = function()
{
if ( this.window.value.length == 0 )
{
wxMessageBox("Please give a username");
return false;
}
return true;
}
userText.validator = validator;
dlg.autoLayout = true;
dlg.layout();
dlg.showModal();
user = validator.value;
return false;
}
wxTheApp.onInit = Application;
Constants
Constructor
wxGenericValidator
wxGenericValidator(Value)
| Name | Type | Default | Description |
|---|---|---|---|
| Value | Any |
This value is used to transfer to the control.
The type of value is important.
|
Constructs a new wxGenericValidator object
Properties
| Name | Type | Description |
|---|---|---|
| validate | Function |
Assign a function to this property that checks the content of the associated window. The function
can have one argument: the parent of the associated window. This function should return false
when the content is invalid, true when it is valid. To get the associated window,
use this.window.
|
value ![]() |
Any | Gets the value. The same type as the argument of the ctor. |

© 2002 - 2007 Franky Braem.