numbercontrol

Inherits

windowcontrol

Inherited By

numberfield

Context

windowinstance

numbercontrol is a window control that contains number data and is not bound to a database node. (See also numberfield)

The number is displayed in the specified font centered on the control.

The control supports the "number" dragdata type by default.


Definition

<numbercontrol name="..." > <min > ... </min> <max > ... </max> <default > ... </default> <description > <text > ... </text> <textres > ... </textres> <field > ... </field> </description> <nodrag /> <nodrop /> <noreset /> <displaysign /> <hideonvalue > ... </hideonvalue> <font > ... </font> <color > ... </color> <delaykeyupdate /> <nokeyedit /> </numbercontrol>

<numbercontrol name="..." >

 

<min > ... </min>

If present, the control will not accept values less than the specified number.

<max > ... </max>

If present, the control will not accept values more than the specified number.

<default > ... </default>

If present, new controls will use this value as their default, instead of zero.

<description >

The string used as the description of a data drag. If no child tags or attributes defined, the enclosed text will be used.

<text > ... </text>

Text to be used as the description

<textres > ... </textres>

String resource to be used as the description

<field > ... </field>

The name of a data node under the window data source containing a string to use as the description

</description>

 

<nodrag />

Disable acting as drag and drop source

<nodrop />

Disable acting as a drag and drop target

<noreset />

Disable reset by using the middle mouse button

<displaysign />

Indicates the number should contain a "+" character when positive

<hideonvalue > ... </hideonvalue>

If present, no number will be drawn for the number value specified here

<font > ... </font>

The name of the font resource used to render the text in this control

<color > ... </color>

The color used to draw the text, in the form #aarrggbb. If not present, the font default color is used. If alpha is zero or not defined, FF is assumed.

<delaykeyupdate />

If present and editing the value of this control using the keyboard, changes won't be written to the database and update event functions will not be called until the focus is moved away from the control

<nokeyedit />

Disable keyboard based editing

</numbercontrol>

 

Interface

getFont

function getFont()

Retrieves the name of the font resource used when rendering the contents of the control.

Return values

(string)
The name of a font resource

getMaxValue

function getMaxValue()

Retrieves the maximum value allowed in the control.

Return values

(number)
The current maximum value

getMinValue

Retrieves the minimum value allowed in the control.

Return values

(number)
The current minimum value

getValue

Retrieves the value of the control.

Return values

(number)
The value contained in the control

hasFocus

This function indicates whether the keyboard focus is in this control, i.e. if a keyboard edit action is underway.

Return values

(boolean)
Returns true if the control has the keyboard focus, false otherwise.

onChar

If present, this function is executed whenever the user types a character into the text field.

Parameters

keycode   (number)   

The key code for the typed character. The Lua function string.char can be used to convert the value into a string.



onEnter

If present, this function is executed whenever the user presses enter when editing the text. This method can be used to support behaviors allowing users to enter multiple records of data using the keyboard.

Return values

(boolean)
If the event returns true, no further processing is done by the framework. If the return value is false, the framework processes the message after the script function (finishing the edit operation or creating a new line based on the multi line spacing property).

onGainFocus

Is called when the control gains the keyboard focus.



onLoseFocus

Is called when the control loses the keyboard focus.



onTab

If present, this function is executed whenever the user presses the tab key when editing this control. This method can be used to support list or table like operation for controls. If the shift key is pressed as well, the parameter will be false

Parameters

forward   (boolean)   

If the tab key is pressed without the shift key being depressed, the value is true, indicating a forward tab operation. If the shift key is depressed, the value is false indicating a backward tab operation.



onValueChanged

If present, this function is executed whenever the value of the number in this control changes.



setColor

Sets the color used when rendering the contents of the control. This setting overrides the color defined in the font used. To restore the use of font resource color, specify nil as the parameter value.

The specified parameter is a color value in a HTML-style string representation, in the format "#AARRGGBB". The components are hexadecimal digits specifying the value of the alpha (transparency), red, green and blue channels, respectively, in the range 0 .. 255. If alpha is not defined, FF is assumed.

Parameters

color   (string)   

The color to be used, or nil to reset the setting. See above for details on the string format.



setDescriptionField

Sets the name of the data node to be used as the source for the string used as the description in the dragdata created when this control is acting as a drag and drop operation source. The node is found by fetching the child node corresponding with the name under the window data source.

Parameters

name   (string)   

The name of the field used as the description string source



setDescriptionText

Sets the string used as the description in the dragdata created when this control is acting as a drag and drop operation source.

Parameters

text   (string)   

The string to use as the description. To disable the functionality, pass the empty string as the parameter.



setFocus

This function requests the framework to either set or reset the keyboard focus to this control.

Parameters

state   (boolean)   [optional]

A value of true sets the focus to this control, a false value resets the focus. When the parameter is omitted (synonymous to passing a nil value), the value is treated as true.



setFont

Sets the name of the font resource used to render the text in the control.

Parameters

fontname   (string)   

The name of a font resource



setMaxValue

Sets the maximum value allowed in the control.

Parameters

value   (number)   

The new maximum value



setMinValue

Sets the minimum value allowed in the control.

Parameters

value   (number)   

The new minimum value



setValue

Sets the value of the number in the control.

Parameters

value   (number)   

The value to set the control to