This is an old revision of the document!
AXNumValidatedTF is a Xojo TextField subclass (32/64 bits) for Windows and macOS allowing the input validation of a defined numeric range, using the system Locale settings for decimal and grouping text formating.
Among other features, the user can set the kind of numerical input (Integer or Real), Minimum and Maximum values for the accepted numerical input, the decimal lenght for real numbers, and the default value for the field. It also provides properties to enforce the input of a numerical value in the defined range (the focus stays in the field) and the optional display of an error message dialog.
As part of the validation process, AXNumValidatedTF properly formats the displayed number, including the use of the Grouping and Decimal character defined in the system Locale settings, the deletion of left side zeroes and even trying to fix the incorrect use of the Grouping and Decimal characters as part of the input from the user (for example, “10,00.32” is formated as “1,000.32” after the validation when the “,” character is set for number Grouping and “.” as the decimal separator).
AXNumValidatedTF formats the Minimum and Maximum values, showing them as a hint in the ToolTip (API 2.0) or HelpTag (API 1) for everyone of the instances used in the Layout of the App.
Besides the usual Methods and Properties availables in a TextField, AXNumValidatedTF adds its own Properties, Methods and Events to simplify the access and notification of the entered values. For example:
IsInRange As Boolean
Is a Property set to True when the entered value is inside the defined Range, and False otherwise.
For those cases when an active notification or propagation of the value is needed, it also provide the following Event Handlers:
ValueInRange (Value As Double)
. Fires when the entered value is inside the defined numeric range for the field.ValueOutOfRange (Value As Double)
. Fires when the entered value is not in the defined numeric range for the field.
Copy the AXNumValidated
folder from the Xojo Demo Project and paste it into your own Xojo Project. Make sure you're copying the right API 2.0 or API 1.0 version of the Demo project.
If your app windows layouts already include TextField you want to use for validation, select them and use the Inspector Panel and change its Super class to AXNumValidatedTF.
Then, and using the Inspector Panel or via code, use the available AXNumValidatedTF properties to
AXNumValidatedTF requires Xojo 2017r3 or later, and is compatible with projects using both API 2.0 and API 1.