IupSpinBox
Definition: |
include pGUI.e
Ihandle ih = IupSpin() -- and -- Ihandle ih = IupSpinBox(Ihandln child=NULL, [[nullable_string action=NULL,] cbfunc func=NULL,] string attributes="", dword_seq args={}) |
Description: |
The IupSpin function creates a control set with a vertical box containing two buttons, one an up arrow and the other down. Typically and intuitively they would be used to increment and decrement values, but there is no absolute law on that. Unlike the SPIN attribute of the IupText element, the IupSpin element does NOT automatically increment the value and it is NOT inserted inside the IupText area (that is, assuming you passed an IupText in as the child). But they can be used with any element. In other words, it is entirely the programmer’s responsibility to implement the desired behaviour of the up/down buttons in the SPIN_CB callback. Omitting the latter makes the control completely useless (except perhaps as part of one of those find-and-seek-the-button-or-control-that-actually-does-something games...). IupSpin inherits from IupVbox, and contains two IupButton. IupSpinBox is a horizontal container that already contains an IupSpin. child: Identifier of an interface element to be placed next to the spinbox. action: Name of the action generated when the button is selected. It can be NULL/omitted. func: a callback address, usually specified as Icallback("name"). For more information on the attributes and args parameters see IupSetAttributes, and IupVbox for a list of the attributes that may apply here. This is a paranormalised function. Returns: the identifier of the created element. |
pwa/p2js: | Not supported (however IupText(SPIN) is fine...) |
See Also: | IupText, IupVbox, IupHbox, IupButton |
Notes: |
If you want a number field with up/down that increment/decrement it automatically, then instead of this
use an IupText() with the SPIN attribute set.
There is an example of just that ("Width:") on the toolbox ("Tools" window) of demo\pGUI\simple_paint.exw
and several more in demo\pGUI\boids3d.exw
An IupSpinBox can be created with no elements and filled dynamically using IupAppend() or IupInsert(). IupSpinbox (with a lower case 'b') is a simple alias of IupSpinBox and behaves identically. See demo\pGUI\spin.exw for an example (not that as-is it does very much, but that’s deliberate). |
Callbacks: | |
SPIN_CB |
Called each time the user clicks in the buttons.
function spin_cb(Ihandle ih, integer inc) With neither Shift or Ctrl held down, inc will be 1 for up and -1 for down. Holding the Shift key will set a factor of 2, holding Ctrl a factor of 10, and both a factor of 100. |
Example: |
Ihandle spinbox = IupSpinBox(IupText()), see also demo\pGUI\spin.exw
![]() |