class numberEdit

superclass(es) maskEdit
subclass(es) -
description The numberEdit class is a mask editor specialised in entering numeric values.

pl_img139.gif (1851 bytes) pl_img140.gif (1836 bytes)
see also panel - editControl - edit

tasks

Create the numberEdit control just like an edit control. Setting options like the justification of the text is done by methods of the classes editControl and edit. The panel class has two methods that make it easier to create a numberEdit control.

The numberEdit class is derived from the maskEdit class and is specialised in entering numbers. It automatically adjusts its mask string while the uses enters and deletes characters. Its default options are based on the Windows settings. With changeMask/6 is it possible to adjust the settings of a numberEdit control.

It is allowed to enter '+' or '-' characters at the beginning of a number (see putAllowSign/1 and allowSign/1). If the user enters a negative number then the textcolor is changed to red (putNegAsRedText/1 and negAsRedText/1). The default number of characters after a decimal separator is 2 (putNumDigitsAfterDecimal/1 and numDigitsAfterDecimal/1).

It is possible with the method putClearAfterFocus/1 to adjust the behavior of a numberEdit control in the situation when the user presses a key after he/she has given the focus to the same control. In this case can the numberEdit clear the numbers already present just like Microsoft Excel. This is not default behavior of the numberEdit control, its default behavior after receiving the keyboard focus is to select all the tex t(see putSelectAllAfterFocus/1).

Default settings

The default settings of a numberEdit control are:

  • The user may enter sign characters like '-' and '+'.
  • Negative numbers are displayed with the red text color.
  • All the text is selected after receiving the keyboard focus.
  • All the other settings are copied from the Windows settings.

methods

number(?Output)

func Attempt to convert the text entered by the user to a floating-point number.
pre TRUE
post If the text entered by the user could not be converted to a number then was no value unified with Output, else a floating-point number was unified with the value of the parameter Output.

putNumber(+Number)

func Assign a numeric value to a numberEdit control.
pre The variable Number must contain a valid number.
post The numeric value was converted to a readable text representation and displayed in the numerEdit control.

changeMask(+DecimalSymbol, +GroupSymbol, +NegativeSymbol, +AllowSign, +GroupSize, +NumDigitsAfterDecimal)

func Change the properties of the numberEdit control. The value of the first parameter is the character that separates the decimals from the numbers. The GroupSymbol character is used to visually separate the characters to the left of the decimal character. The NegativeSymbol character is used to indicate if the number is negative or not, it always appears to the left of the numbers. The boolean value of the parameter AllowSign determines if negative numbers may be entered or not. The size of groups to the left of the decimal separator is determined by the value of GroupSize. How many numbers may appear after the decimal separator is set by the value of NumDigitsAfterDecimal.
pre The values of the parameters DecimalSymbol, GroupSymbol and NegativeSymbol must be atoms of 1 character. The value of AllowSign must be a boolean. The GroupSize and NumDigitsAfterDecimal parameters must be 0 or positive integers.
post The values of all the properties were stored. To have these new values take effect call the method createMask/1.

createMask(+Output)

func Create a new mask based on the current settings stored by the numberEdit control. It is necessary to call createMask after changeMask/1 was used to change the settings.
pre TRUE
post If the mask was successfully created then was true unified with Output, else false.

putNegAsRedText(+YesNo)

func Determine if negative numbers are displayed with the red textcolor or not. This is default behavior of the numberEdit control.
pre The parameter YesNo must have a boolean value.
post Default is that negative numbers are displayed with the red text color, if the value of YesNo was false then are negative numbers displayed as black text.

negAsRedText(?YesNo)

func Check if negative numbers are displayed with the red textcolor or not.
pre TRUE
post If the value of YesNo was unified with true then are negative numbers displayed as red text, else not.

putDecimalSymbol(+Symbol)

func Set the decimal symbol to use by the numberEdit control. The default decimal symbol used is determined by the local Windows settings.
pre The value of the parameter Symbol must be an atom of 1 character.
post The value of the parameter Symbol was stored as the decimal separator.

decimalSymbol(?Symbol)

func Get the decimal symbol used by the numberEdit control. The default decimal symbol used is determined by the local Windows settings.
pre TRUE
post The decimal separator was unified with the value of the parameter Symbol.

putGroupSymbol(+Symbol)

func Set the group symbol to use by the numberEdit control. The default group symbol used is determined by the local Windows settings.
pre The value of the parameter Symbol must be an atom of 1 character.
post The value of the parameter Symbol was stored as the group separator.

groupSymbol(?Symbol)

func Get the group symbol used by the numberEdit control. The default group symbol used is determined by the local Windows settings.
pre TRUE
post The group separator was unified with the value of the parameter Symbol.

putNegativeSymbol(+Symbol)

func Set the negative symbol to use by the numberEdit control. The default negative symbol used is determined by the local Windows settings.
pre The value of the parameter Symbol must be an atom of 1 character.
post The value of the parameter Symbol was stored as the negative separator.

negativeSymbol(?Symbol)

func Get the negative symbol used by the numberEdit control. The default negative symbol used is determined by the local Windows settings.
pre TRUE
post The negative character was unified with the value of the parameter Symbol.

putGroupSize(+Size)

func Set the group size to use by the numberEdit control. The default group size is determined by the local Windows settings.
pre The value of the parameter Size must be an integer.
post The value of the parameter Size was stored as the group size.

groupSize(?Output)

func Get the group size used by the numberEdit control. The default size of groups is determined by the local Windows settings.
pre TRUE
post The group size was unified with the value of the parameter Output.

putNumDigitsAfterDecimal(+Size)

func Set the number of digits to the right of the decimal separator. The default number of decimal digits is determined by the local Windows settings.
pre The value of the parameter Size must be an integer.
post The value of the parameter Size was stored as the number of decimals.

numDigitsAfterDecimal(?Output)

func Get the number of digits to the right of the decimal separator. The default number of decimal digits is determined by the local Windows settings.
pre TRUE
post The number of decimals was unified with the value of the parameter Output.

putMaxBeforeDecimal(+Val)

func Set the maximum number of digits to the left of the decimal separator. Default is there no maximum and is the value of this attribute 0.
pre The value of the parameter Val must be an integer.
post The value of the parameter Val was stored as the maximum number of decimals to the left of the decimal separator. If the value of Val was 0 then there is no maximum on the number of characters that a user may enter.

maxBeforeDecimal(?Output)

func Get the maximum number of digits that the user can enter to the left of the decimal separator.
pre TRUE
post The value of the attribute that determines the maximum number of decimals to the left of the decimal separator was unified with the value of the variable Output.

putAllowSign(+YesNo)

func Determine if the user may enter '-' or '+' characters. These characters indicate the sign of a numeric value. This is default behavior of the numberEdit control.
pre The value of the parameter YesNo must be boolean.
post Default is that the user can enter a '-' or '+' character, if the value of YesNo was false then is this no longer allowed.

allowSign(?Output)

func Check if the user may enter '-' or '+' characters.
pre TRUE
post If the user may enter a '-' or '+' character then was true unified with the value Output, else not and was false unified with Output.

putClearAfterFocus(+YesNo)

func Determine if the contents of the control is cleared after it has received the keyboard focus and the user enters a valid character. A valid character is a sign character (the '-' or '+'), a decimal separator or a number. This is not default behavior of the numberEdit control.
pre The value of the parameter YesNo must be boolean.
post If YesNo was true then is the contents of the numberEdit control cleared after receiving the keyboard focus and the user enters a valid character.

clearAfterFocus(?Output)

func Check if the contents of the control is cleared after it has received the keyboard focus and the user enters a valid character. A valid character is a sign character (the '-' or '+'), a decimal separator or a number. This is not default behavior of the numberEdit control.
pre TRUE
post If the parameter Output was unified with the value true then is the contents of the numberEdit control cleared after receiving the keyboard focus and the user entering a valid character, else not and was false unified with the parameter Output.

putSelectAllAfterFocus(+YesNo)

func Determine if all the text in the control is selected after it has received the keyboard focus. This is default behavior of the numberEdit control.
pre The value of the parameter YesNo must be boolean.
post If YesNo was true then is all the contents of the numberEdit control selected after receiving the keyboard focus.

selectAllAfterFocus(?Output)

func Check if all the text of the control is selected after it has received the keyboard focus.
pre TRUE
post If the parameter Output was unified with the value true then is the contents of the numberEdit selected after receiving the keyboard focus.