NumberBox:
Filter:
Classes | GUI > Views

NumberBox : QAbstractStepValue : AbstractStepValue : View : QObject : Object

A view displaying a modifiable numerical value.
Subclasses: QNumberBox

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

Undocumented class methods

NumberBox.new(parent, bounds)

NumberBox.qtClass

Instance Methods

Data

.value

.value = value

Numerical value between 0 and 1.

Arguments:

value

A Float.

.valueAction = val

Sets -value to the argument and triggers -action.

.increment(factor: 1.0)

From superclass: AbstractStepValue

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

Arguments:

factor

Any number.

.decrement(factor: 1.0)

From superclass: AbstractStepValue

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

Arguments:

factor

Any number.

.string

.string = string

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

Arguments:

string

A String.

.object

.object = obj

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

Arguments:

obj

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

.setBoth

.setBoth = value

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

Arguments:

(arg1)

A Boolean.

Restrictions on data

.clipLo

.clipLo = aFloat

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

Arguments:

aFloat

A Float.

.clipHi

.clipHi = aFloat

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

Arguments:

aFloat

A Float.

.minDecimals

.minDecimals = decimals

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:

decimals

An Integer.

.maxDecimals

.maxDecimals = decimals

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

Arguments:

decimals

An Integer.

.decimals

.decimals = decimals

Sets both -minDecimals and -maxDecimals to the argument.

Arguments:

decimals

An Integer.

Appearance

.align

.align = alignment

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

.stringColor

.stringColor = color

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

Arguments:

color

A Color.

.normalColor

.normalColor = aColor

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

Arguments:

aColor

A Color.

.typingColor

.typingColor = aColor

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

Arguments:

aColor

A Color.

Interaction

.step

.step = aFloat

From superclass: AbstractStepValue

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

Arguments:

aFloat

A Float.

.scroll_step

.scroll_step = aFloat

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

Arguments:

aFloat

A Float.

.shift_scale

.shift_scale = aFloat

From superclass: AbstractStepValue

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:

aFloat

A Float.

.ctrl_scale

.ctrl_scale = aFloat

From superclass: AbstractStepValue

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:

aFloat

A Float.

.alt_scale

.alt_scale = aFloat

From superclass: AbstractStepValue

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:

aFloat

A Float.

Actions

.action

.action = func

From superclass: View

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

.defaultKeyDownAction(char, modifiers, unicode, keycode, key)

From superclass: View

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

Undocumented instance methods

.background

.background = color

.buttonsVisible

.buttonsVisible = aBool

.initNumberBox

.scroll

.scroll = aBool

Examples

Basic Example

Sound Example

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