NumberBox:
Filter:
Classes | GUI > Views

NumberBox

A view displaying a modifiable numerical value.
Location: NOT INSTALLED!

Description

A view that displays a numerical value and allows to modify it by typing the value in, and incrementing or decrementing it using the keyboard, or mouse.

Using the keyboard, the value will change on each arrow key press by the amount defined by -step.

Mouse scrolling is performed by pressing a mouse button inside the view and dragging the mouse vertically. The value will change according to the mouse cursor movement, in steps defined by -scroll_step.

By default, holding down the Shift, Ctrl, or Alt key while incrementing or decrementing the value will multiply the steps by 100, 10, or 0.1 respectively, though you can customize this by setting -shift_scale, -ctrl_scale, or -alt_scale. Scrolling can be enabled or disabled by modifying the -scroll variable.

Class Methods

Inherited class methods

Instance Methods

Data

.value

Numerical value between 0 and 1.

Arguments:

A Float.

.valueAction

Sets -value to the argument and triggers -action.

.increment

Increments the value by -step multiplied by 'factor'.

Arguments:

factor

Any number.

.decrement

Decrements the value by -step multiplied by 'factor'.

Arguments:

factor

Any number.

.string

Text to be displayed instead of the numerical value. Setting -value after this will display the value again.

Arguments:

A String.

.object

If -setBoth is true, setting this variable also sets -string to the argument interpreted as String.

Arguments:

Any object, typically one which makes sense to display as a string, such as a Float.

.setBoth

A variable stating whether setting -object will also set -string.

Arguments:

A Boolean.

Restrictions on data

.clipLo

The lowest numerical value allowed. Trying to set a lower value will clip it to this.

Arguments:

A Float.

.clipHi

The highest numerical value allowed. Trying to set a higher value will clip it to this.

Arguments:

A Float.

.minDecimals

The minimum amount of decimal places displayed. If the value can be completely described with less decimal places, zeros will be appended until reaching this.

Arguments:

An Integer.

.maxDecimals

The maximum amount of decimal places displayed. The value will always be rounded to this amount of decimals.

Arguments:

An Integer.

.decimals

Sets both -minDecimals and -maxDecimals to the argument.

Arguments:

An Integer.

Appearance

.align

The alignment of the displayed value. See Alignment for possible values.

.stringColor

The color used to display the value before it is ever changed by user interaction.

Arguments:

A Color.

.normalColor

The color used to display the value after is has been typed in.

Arguments:

A Color.

.typingColor

The color used to display the value while it is being typed in.

Arguments:

A Color.

Interaction

.step

The amount by which the value will changed when -increment or -decrement is called, or when related keys are pressed.

Arguments:

A Float.

.scroll_step

The amount by which the value will changed when scrolled using the mouse.

Arguments:

A Float.

.shift_scale

The factor by which -step or -scroll_step is multiplied when incrementing or decrementing the value using keyboard or mouse while the Shift key is pressed.

Arguments:

A Float.

.ctrl_scale

The factor by which -step or -scroll_step is multiplied when incrementing or decrementing the value using keyboard or mouse while the Ctrl key is pressed.

Arguments:

A Float.

.alt_scale

The factor by which -step or -scroll_step is multiplied when incrementing or decrementing the value using keyboard or mouse while the Alt key is pressed.

Arguments:

A Float.

Actions

.action

The action object evaluated whenever the user changes the value by interacting with the view.

.defaultKeyDownAction

Any key representing a character that can make part of a floating point number representation will initiated the editing of the value. Pressing Return (or Enter) will finish the editing and store the value typed in as a Float.

Aside from that, this method implements the default effects of key presses as follows:

KeyEffect
up arrowincrement
down arrowdecrement
right arrowincrement
left arrowdecrement

Drag and drop

.defaultGetDrag

Returns:

The -value.

.defaultCanReceiveDrag

Returns:

True if the current drag data is a number.

.defaultReceiveDrag

Sets -valueAction to the current drag data.

Inherited instance methods

Examples

Basic Example

Sound Example

Change frequency of a playing synth by step using arrow keys: