public class SpinButton extends Entry
It is used to let the user introduce the value of a numeric property. This
is specially useful when the range of allowed values is unlimited (well, in
practise limited by Double.MAX_VALUE
!) or only limited at one
end. Otherwise, a control like Scale
may be a better alternative.
It is also a good idea to add near the SpinButton a Label indicating the units of measure of the property it refers to.
The user can modify the SpinButton either introducing a numeric value in
the required range in the text entry, or by clicking the arrow Buttons. The
keyboard can also be used, with both the Up
and
Down
, or with the PageUp
or
PageDown
keys. These last decrement or increment the value
of the entry by a greater amount (usually ten times the value of the arrow
Button step).
The programmer can get the value introduced by the user with the
getValue()
method. While this method returns a
double
, by default the SpinButton only allows to introduce
integer values. You can use the setDigits()
method
to change this behaviour.
Modifier and Type | Class and Description |
---|---|
static interface |
SpinButton.ValueChanged
Signal emitted when the value of the SpinButton changes, either by
clicking the arrow buttons, by pressing the specified keys, by input a
new value on the text entry, or by setting it programmatically with
setValue() method. |
Entry.Activate, Entry.Changed, Entry.IconPress, Entry.IconRelease
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
Constructor and Description |
---|
SpinButton(double min,
double max,
double step)
Create a new SpinButton.
|
Modifier and Type | Method and Description |
---|---|
void |
connect(SpinButton.ValueChanged handler)
Hook up a handler for the
SpinButton.ValueChanged signal. |
double |
getValue()
Get the current numeric value of the SpinButton.
|
void |
setDigits(int digits)
Set the number of decimal digits to allow in the entry.
|
void |
setValue(double value)
Set the value displayed in the text entry.
|
connect, connect, connect, connect, connect, getCompletion, getIconActivatable, getIconAtPos, getIconIcon, getIconPixbuf, getIconSensitive, getIconStock, getIconStorageType, getIconTooltipMarkup, getIconTooltipText, getMaxLength, getOverwriteMode, getPosition, getProgressFraction, getProgressPulseStep, getSelectionBoundsEnd, getSelectionBoundsStart, getText, getTextLength, getVisibility, progressPulse, selectRegion, setAlignment, setCompletion, setEditable, setHasFrame, setIconActivatable, setIconFromIcon, setIconFromPixbuf, setIconFromStock, setIconSensitive, setIconTooltipMarkup, setIconTooltipText, setInnerBorder, setInvisibleChar, setMaxLength, setOverwriteMode, setPosition, setProgressFraction, setProgressPulseStep, setText, setVisibility, setWidthChars
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
public SpinButton(double min, double max, double step)
min
- The minimum value allowed.max
- The maximum value allowed.step
- The amount to increment/decrement when one of the arrow
Buttons are clicked, or when the user press the
Up
or Down
keys.public void connect(SpinButton.ValueChanged handler)
SpinButton.ValueChanged
signal.public double getValue()
public void setDigits(int digits)
step
you have chosen,
otherwise you will get an undesired behaviour.public void setValue(double value)
setDigits()
), the next time user increments or
decrements its values the additional digits will be lost, so take care
about this.