gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.SpinButton

Contents

- Exported types
- Methods
  - configure
  - getActivatesDefault
  - getAdjustment
  - getClimbRate
  - getDigits
  - getIncrements
  - getNumeric
  - getRange
  - getSnapToTicks
  - getUpdatePolicy
  - getValue
  - getValueAsInt
  - getWrap
  - new
  - newWithRange
  - setActivatesDefault
  - setAdjustment
  - setClimbRate
  - setDigits
  - setIncrements
  - setNumeric
  - setRange
  - setSnapToTicks
  - setUpdatePolicy
  - setValue
  - setWrap
  - spin
  - update
- Properties
  - activatesDefault
  - adjustment
  - climbRate
  - digits
  - numeric
  - snapToTicks
  - updatePolicy
  - value
  - wrap
- Signals
  - activate
  - changeValue
  - input
  - output
  - valueChanged
  - wrapped

Description

Allows to enter or change numeric values.

<picture> <source srcset="spinbutton-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkSpinButton" src="spinbutton.png"> </picture>

Rather than having to directly type a number into a `GtkEntry`, `GtkSpinButton` allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.

The main properties of a `GtkSpinButton` are through an adjustment. See the `Adjustment` documentation for more details about an adjustment's properties.

Note that `GtkSpinButton` will by default make its entry large enough to accommodate the lower and upper bounds of the adjustment. If this is not desired, the automatic sizing can be turned off by explicitly setting Editable:widthChars to a value != -1.

## Using a GtkSpinButton to get an integer

### c code

    // Provides a function to retrieve an integer value from a GtkSpinButton
    // and creates a spin button to model percentage values.

    int
    grab_int_value (GtkSpinButton *button,
                    gpointer       user_data)
    {
      return gtk_spin_button_get_value_as_int (button);
    }

    void
    create_integer_spin_button (void)
    {

      GtkWidget *window, *button;
      GtkAdjustment *adjustment;

      adjustment = gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 0.0);

      window = gtk_window_new ();

      // creates the spinbutton, with no decimal places
      button = gtk_spin_button_new (adjustment, 1.0, 0);
      gtk_window_set_child (GTK_WINDOW (window), button);

      gtk_window_present (GTK_WINDOW (window));
    }

## Using a GtkSpinButton to get a floating point value

### c code

    // Provides a function to retrieve a floating point value from a
    // GtkSpinButton, and creates a high precision spin button.

    float
    grab_float_value (GtkSpinButton *button,
                      gpointer       user_data)
    {
      return gtk_spin_button_get_value (button);
    }

    void
    create_floating_spin_button (void)
    {
      GtkWidget *window, *button;
      GtkAdjustment *adjustment;

      adjustment = gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.0);

      window = gtk_window_new ();

      // creates the spinbutton, with three decimal places
      button = gtk_spin_button_new (adjustment, 0.001, 3);
      gtk_window_set_child (GTK_WINDOW (window), button);

      gtk_window_present (GTK_WINDOW (window));
    }

# Shortcuts and Gestures

The following signals have default keybindings:

- SpinButton::changeValue

# CSS nodes

    spinbutton.horizontal
    ├── text
    │    ├── undershoot.left
    │    ╰── undershoot.right
    ├── button.down
    ╰── button.up

    spinbutton.vertical
    ├── button.up
    ├── text
    │    ├── undershoot.left
    │    ╰── undershoot.right
    ╰── button.down

`GtkSpinButton`s main CSS node has the name spinbutton. It creates subnodes for the entry and the two buttons, with these names. The button nodes have the style classes .up and .down. The `GtkText` subnodes (if present) are put below the text node. The orientation of the spin button is reflected in the .vertical or .horizontal style class on the main node.

# Accessibility

`GtkSpinButton` uses the `AccessibleRoleSpinButton` role.

Synopsis

- newtype SpinButton = SpinButton (ManagedPtr SpinButton)
- class (GObject o, IsDescendantOf SpinButton o) => IsSpinButton o
- toSpinButton :: (MonadIO m, IsSpinButton o) => o -> m SpinButton
- spinButtonConfigure :: (HasCallStack, MonadIO m, IsSpinButton a, IsAdjustment b) => a -> Maybe b -> Double -> Word32 -> m ()
- spinButtonGetActivatesDefault :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Bool
- spinButtonGetAdjustment :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Adjustment
- spinButtonGetClimbRate :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Double
- spinButtonGetDigits :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Word32
- spinButtonGetIncrements :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m (Double, Double)
- spinButtonGetNumeric :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Bool
- spinButtonGetRange :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m (Double, Double)
- spinButtonGetSnapToTicks :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Bool
- spinButtonGetUpdatePolicy :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m SpinButtonUpdatePolicy
- spinButtonGetValue :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Double
- spinButtonGetValueAsInt :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Int32
- spinButtonGetWrap :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m Bool
- spinButtonNew :: (HasCallStack, MonadIO m, IsAdjustment a) => Maybe a -> Double -> Word32 -> m SpinButton
- spinButtonNewWithRange :: (HasCallStack, MonadIO m) => Double -> Double -> Double -> m SpinButton
- spinButtonSetActivatesDefault :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Bool -> m ()
- spinButtonSetAdjustment :: (HasCallStack, MonadIO m, IsSpinButton a, IsAdjustment b) => a -> b -> m ()
- spinButtonSetClimbRate :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Double -> m ()
- spinButtonSetDigits :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Word32 -> m ()
- spinButtonSetIncrements :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Double -> Double -> m ()
- spinButtonSetNumeric :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Bool -> m ()
- spinButtonSetRange :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Double -> Double -> m ()
- spinButtonSetSnapToTicks :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Bool -> m ()
- spinButtonSetUpdatePolicy :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> SpinButtonUpdatePolicy -> m ()
- spinButtonSetValue :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Double -> m ()
- spinButtonSetWrap :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> Bool -> m ()
- spinButtonSpin :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> SpinType -> Double -> m ()
- spinButtonUpdate :: (HasCallStack, MonadIO m, IsSpinButton a) => a -> m ()
- constructSpinButtonActivatesDefault :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpinButtonActivatesDefault :: (MonadIO m, IsSpinButton o) => o -> m Bool
- setSpinButtonActivatesDefault :: (MonadIO m, IsSpinButton o) => o -> Bool -> m ()
- constructSpinButtonAdjustment :: (IsSpinButton o, MonadIO m, IsAdjustment a) => a -> m (GValueConstruct o)
- getSpinButtonAdjustment :: (MonadIO m, IsSpinButton o) => o -> m Adjustment
- setSpinButtonAdjustment :: (MonadIO m, IsSpinButton o, IsAdjustment a) => o -> a -> m ()
- constructSpinButtonClimbRate :: (IsSpinButton o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpinButtonClimbRate :: (MonadIO m, IsSpinButton o) => o -> m Double
- setSpinButtonClimbRate :: (MonadIO m, IsSpinButton o) => o -> Double -> m ()
- constructSpinButtonDigits :: (IsSpinButton o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getSpinButtonDigits :: (MonadIO m, IsSpinButton o) => o -> m Word32
- setSpinButtonDigits :: (MonadIO m, IsSpinButton o) => o -> Word32 -> m ()
- constructSpinButtonNumeric :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpinButtonNumeric :: (MonadIO m, IsSpinButton o) => o -> m Bool
- setSpinButtonNumeric :: (MonadIO m, IsSpinButton o) => o -> Bool -> m ()
- constructSpinButtonSnapToTicks :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpinButtonSnapToTicks :: (MonadIO m, IsSpinButton o) => o -> m Bool
- setSpinButtonSnapToTicks :: (MonadIO m, IsSpinButton o) => o -> Bool -> m ()
- constructSpinButtonUpdatePolicy :: (IsSpinButton o, MonadIO m) => SpinButtonUpdatePolicy -> m (GValueConstruct o)
- getSpinButtonUpdatePolicy :: (MonadIO m, IsSpinButton o) => o -> m SpinButtonUpdatePolicy
- setSpinButtonUpdatePolicy :: (MonadIO m, IsSpinButton o) => o -> SpinButtonUpdatePolicy -> m ()
- constructSpinButtonValue :: (IsSpinButton o, MonadIO m) => Double -> m (GValueConstruct o)
- getSpinButtonValue :: (MonadIO m, IsSpinButton o) => o -> m Double
- setSpinButtonValue :: (MonadIO m, IsSpinButton o) => o -> Double -> m ()
- constructSpinButtonWrap :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpinButtonWrap :: (MonadIO m, IsSpinButton o) => o -> m Bool
- setSpinButtonWrap :: (MonadIO m, IsSpinButton o) => o -> Bool -> m ()
- type SpinButtonActivateCallback = IO ()
- afterSpinButtonActivate :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonActivateCallback) -> m SignalHandlerId
- onSpinButtonActivate :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonActivateCallback) -> m SignalHandlerId
- type SpinButtonChangeValueCallback = ScrollType -> IO ()
- afterSpinButtonChangeValue :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonChangeValueCallback) -> m SignalHandlerId
- onSpinButtonChangeValue :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonChangeValueCallback) -> m SignalHandlerId
- type SpinButtonInputCallback = IO (Int32, Double)
- afterSpinButtonInput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonInputCallback) -> m SignalHandlerId
- onSpinButtonInput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonInputCallback) -> m SignalHandlerId
- type SpinButtonOutputCallback = IO Bool
- afterSpinButtonOutput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonOutputCallback) -> m SignalHandlerId
- onSpinButtonOutput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonOutputCallback) -> m SignalHandlerId
- type SpinButtonValueChangedCallback = IO ()
- afterSpinButtonValueChanged :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonValueChangedCallback) -> m SignalHandlerId
- onSpinButtonValueChanged :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonValueChangedCallback) -> m SignalHandlerId
- type SpinButtonWrappedCallback = IO ()
- afterSpinButtonWrapped :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonWrappedCallback) -> m SignalHandlerId
- onSpinButtonWrapped :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonWrappedCallback) -> m SignalHandlerId

# Exported types

newtype SpinButton Source #

Memory-managed wrapper type.

Constructors

SpinButton (ManagedPtr SpinButton) |

#### Instances

Instances details

Eq SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton Methods (==) :: SpinButton -> SpinButton -> Bool Source # (/=) :: SpinButton -> SpinButton -> Bool Source #
GObject SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton
ManagedPtrNewtype SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton Methods toManagedPtr :: SpinButton -> ManagedPtr SpinButton Source #
TypedObject SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton Methods glibType :: IO GType Source #
HasParentTypes SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton
IsGValue (Maybe SpinButton) Source # | Convert `SpinButton` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.SpinButton Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe SpinButton -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe SpinButton) Source #
type ParentTypes SpinButton Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton type ParentTypes SpinButton = '[Widget, Object, Accessible, AccessibleRange, Buildable, CellEditable, ConstraintTarget, Editable, Orientable]

class (GObject o, IsDescendantOf SpinButton o) => IsSpinButton o Source #

Type class for types which can be safely cast to `SpinButton`, for instance with `toSpinButton`.

#### Instances

Instances details

(GObject o, IsDescendantOf SpinButton o) => IsSpinButton o Source # |
Instance details Defined in GI.Gtk.Objects.SpinButton

toSpinButton :: (MonadIO m, IsSpinButton o) => o -> m SpinButton Source #

Cast to `SpinButton`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, configure, contains, createPangoContext, createPangoLayout, delegateGetAccessiblePlatformState, deleteSelection, deleteText, disposeTemplate, dragCheckThreshold, editingDone, errorBell, finishDelegate, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initDelegate, initTemplate, insertActionGroup, insertAfter, insertBefore, insertText, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, removeWidget, resetProperty, resetRelation, resetState, runDispose, selectRegion, shouldLayout, show, sizeAllocate, snapshotChild, spin, startEditing, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, update, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState, watchClosure.

#### Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getActivatesDefault, getAdjustment, getAlignment, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChars, getChildVisible, getClimbRate, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDelegate, getDigits, getDirection, getDisplay, getEditable, getEnableUndo, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getIncrements, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMaxWidthChars, getName, getNative, getNextAccessibleSibling, getNextSibling, getNumeric, getOpacity, getOrientation, getOverflow, getPangoContext, getParent, getPlatformState, getPosition, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRange, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSelectionBounds, getSensitive, getSettings, getSize, getSizeRequest, getSnapToTicks, getStateFlags, getStyleContext, getTemplateChild, getText, getTooltipMarkup, getTooltipText, getUpdatePolicy, getValign, getValue, getValueAsInt, getVexpand, getVexpandSet, getVisible, getWidth, getWidthChars, getWrap.

#### Setters

setAccessibleParent, setActivatesDefault, setAdjustment, setAlignment, setCanFocus, setCanTarget, setChildVisible, setClimbRate, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDigits, setDirection, setEditable, setEnableUndo, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setIncrements, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMaxWidthChars, setName, setNumeric, setOpacity, setOrientation, setOverflow, setParent, setPosition, setProperty, setRange, setReceivesDefault, setSensitive, setSizeRequest, setSnapToTicks, setStateFlags, setText, setTooltipMarkup, setTooltipText, setUpdatePolicy, setValign, setValue, setVexpand, setVexpandSet, setVisible, setWidthChars, setWrap.

## configure

spinButtonConfigure Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a, IsAdjustment b) |
=> a | `spinButton`: a `GtkSpinButton`
-> Maybe b | `adjustment`: a `GtkAdjustment` to replace the spin button’s existing adjustment, or `Nothing` to leave its current adjustment unchanged
-> Double | `climbRate`: the new climb rate
-> Word32 | `digits`: the number of decimal places to display in the spin button
-> m () |

Changes the properties of an existing spin button.

The adjustment, climb rate, and number of decimal places are updated accordingly.

## getActivatesDefault

spinButtonGetActivatesDefault Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Bool | Returns: `True` if the spin button will activate the default widget

Retrieves the value set by `spinButtonSetActivatesDefault`.

Since: 4.14

## getAdjustment

spinButtonGetAdjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Adjustment | Returns: the `GtkAdjustment` of `spinButton`

Get the adjustment associated with a `GtkSpinButton`.

## getClimbRate

spinButtonGetClimbRate Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Double | Returns: the acceleration rate

Returns the acceleration rate for repeated changes.

## getDigits

spinButtonGetDigits Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Word32 | Returns: the current precision

Fetches the precision of `spinButton`.

## getIncrements

spinButtonGetIncrements Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m (Double, Double) |

Gets the current step and page the increments used by `spinButton`.

See `spinButtonSetIncrements`.

## getNumeric

spinButtonGetNumeric Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Bool | Returns: `True` if only numeric text can be entered

Returns whether non-numeric text can be typed into the spin button.

## getRange

spinButtonGetRange Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m (Double, Double) |

Gets the range allowed for `spinButton`.

See `spinButtonSetRange`.

## getSnapToTicks

spinButtonGetSnapToTicks Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Bool | Returns: `True` if values are snapped to the nearest step

Returns whether the values are corrected to the nearest step.

## getUpdatePolicy

spinButtonGetUpdatePolicy Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m SpinButtonUpdatePolicy | Returns: the current update policy

Gets the update behavior of a spin button.

See `spinButtonSetUpdatePolicy`.

## getValue

spinButtonGetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Double | Returns: the value of `spinButton`

Get the value in the `spinButton`.

## getValueAsInt

spinButtonGetValueAsInt Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Int32 | Returns: the value of `spinButton`

Get the value `spinButton` represented as an integer.

## getWrap

spinButtonGetWrap Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m Bool | Returns: `True` if the spin button wraps around

Returns whether the spin button’s value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.

## new

spinButtonNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsAdjustment a) |
=> Maybe a | `adjustment`: the `GtkAdjustment` that this spin button should use
-> Double | `climbRate`: specifies by how much the rate of change in the value will accelerate if you continue to hold down an up/down button or arrow key
-> Word32 | `digits`: the number of decimal places to display
-> m SpinButton | Returns: The new `GtkSpinButton`

Creates a new `GtkSpinButton`.

## newWithRange

spinButtonNewWithRange Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Double | `min`: Minimum allowable value
-> Double | `max`: Maximum allowable value
-> Double | `step`: Increment added or subtracted by spinning the widget
-> m SpinButton | Returns: The new `GtkSpinButton`

Creates a new `GtkSpinButton` with the given properties.

This is a convenience constructor that allows creation of a numeric `GtkSpinButton` without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 * `step` is the default. The precision of the spin button is equivalent to the precision of `step`.

Note that the way in which the precision is derived works best if `step` is a power of ten. If the resulting precision is not suitable for your needs, use `spinButtonSetDigits` to correct it.

## setActivatesDefault

spinButtonSetActivatesDefault Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Bool | `activatesDefault`: `True` to activate window’s default widget on activation
-> m () |

Sets whether activating the spin button will activate the default widget for the window containing the spin button.

See SpinButton::activate for what counts as activation.

Since: 4.14

## setAdjustment

spinButtonSetAdjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a, IsAdjustment b) |
=> a | `spinButton`: a `GtkSpinButton`
-> b | `adjustment`: a `GtkAdjustment` to replace the existing adjustment
-> m () |

Replaces the `GtkAdjustment` associated with `spinButton`.

## setClimbRate

spinButtonSetClimbRate Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Double | `climbRate`: the rate of acceleration, must be >= 0
-> m () |

Sets the acceleration rate for repeated changes when you hold down a button or key.

## setDigits

spinButtonSetDigits Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Word32 | `digits`: the number of digits after the decimal point to be displayed for the spin button’s value
-> m () |

Set the precision to be displayed by `spinButton`.

Up to 20 digit precision is allowed.

## setIncrements

spinButtonSetIncrements Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Double | `step`: increment applied for a button 1 press.
-> Double | `page`: increment applied for a button 2 press.
-> m () |

Sets the step and page increments for spin_button.

This affects how quickly the value changes when the spin button’s arrows are activated.

## setNumeric

spinButtonSetNumeric Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Bool | `numeric`: flag indicating if only numeric entry is allowed
-> m () |

Sets the flag that determines if non-numeric text can be typed into the spin button.

## setRange

spinButtonSetRange Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Double | `min`: minimum allowable value
-> Double | `max`: maximum allowable value
-> m () |

Sets the minimum and maximum allowable values for `spinButton`.

If the current value is outside this range, it will be adjusted to fit within the range, otherwise it will remain unchanged.

## setSnapToTicks

spinButtonSetSnapToTicks Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Bool | `snapToTicks`: a flag indicating if invalid values should be corrected
-> m () |

Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.

## setUpdatePolicy

spinButtonSetUpdatePolicy Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> SpinButtonUpdatePolicy | `policy`: a `GtkSpinButtonUpdatePolicy` value
-> m () |

Sets the update behavior of a spin button.

This determines whether the spin button is always updated or only when a valid value is set.

## setValue

spinButtonSetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Double | `value`: the new value
-> m () |

Sets the value of `spinButton`.

## setWrap

spinButtonSetWrap Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> Bool | `wrap`: a flag indicating if wrapping behavior is performed
-> m () |

Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.

## spin

spinButtonSpin Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> SpinType | `direction`: a `GtkSpinType` indicating the direction to spin
-> Double | `increment`: step increment to apply in the specified direction
-> m () |

Increment or decrement a spin button’s value in a specified direction by a specified amount.

## update

spinButtonUpdate Source #

Arguments

:: (HasCallStack, MonadIO m, IsSpinButton a) |
=> a | `spinButton`: a `GtkSpinButton`
-> m () |

Manually force an update of the spin button.

# Properties

## activatesDefault

Whether to activate the default widget when the spin button is activated.

See SpinButton::activate for what counts as activation.

Since: 4.14

constructSpinButtonActivatesDefault :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`activates-default`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonActivatesDefault :: (MonadIO m, IsSpinButton o) => o -> m Bool Source #

Get the value of the “`activates-default`” property. When overloading is enabled, this is equivalent to

    get spinButton #activatesDefault

setSpinButtonActivatesDefault :: (MonadIO m, IsSpinButton o) => o -> Bool -> m () Source #

Set the value of the “`activates-default`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #activatesDefault := value ]

## adjustment

The adjustment that holds the value of the spin button.

constructSpinButtonAdjustment :: (IsSpinButton o, MonadIO m, IsAdjustment a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`adjustment`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonAdjustment :: (MonadIO m, IsSpinButton o) => o -> m Adjustment Source #

Get the value of the “`adjustment`” property. When overloading is enabled, this is equivalent to

    get spinButton #adjustment

setSpinButtonAdjustment :: (MonadIO m, IsSpinButton o, IsAdjustment a) => o -> a -> m () Source #

Set the value of the “`adjustment`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #adjustment := value ]

## climbRate

The acceleration rate when you hold down a button or key.

constructSpinButtonClimbRate :: (IsSpinButton o, MonadIO m) => Double -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`climb-rate`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonClimbRate :: (MonadIO m, IsSpinButton o) => o -> m Double Source #

Get the value of the “`climb-rate`” property. When overloading is enabled, this is equivalent to

    get spinButton #climbRate

setSpinButtonClimbRate :: (MonadIO m, IsSpinButton o) => o -> Double -> m () Source #

Set the value of the “`climb-rate`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #climbRate := value ]

## digits

The number of decimal places to display.

constructSpinButtonDigits :: (IsSpinButton o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`digits`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonDigits :: (MonadIO m, IsSpinButton o) => o -> m Word32 Source #

Get the value of the “`digits`” property. When overloading is enabled, this is equivalent to

    get spinButton #digits

setSpinButtonDigits :: (MonadIO m, IsSpinButton o) => o -> Word32 -> m () Source #

Set the value of the “`digits`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #digits := value ]

## numeric

Whether non-numeric characters should be ignored.

constructSpinButtonNumeric :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`numeric`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonNumeric :: (MonadIO m, IsSpinButton o) => o -> m Bool Source #

Get the value of the “`numeric`” property. When overloading is enabled, this is equivalent to

    get spinButton #numeric

setSpinButtonNumeric :: (MonadIO m, IsSpinButton o) => o -> Bool -> m () Source #

Set the value of the “`numeric`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #numeric := value ]

## snapToTicks

Whether erroneous values are automatically changed to the spin buttons nearest step increment.

constructSpinButtonSnapToTicks :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`snap-to-ticks`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonSnapToTicks :: (MonadIO m, IsSpinButton o) => o -> m Bool Source #

Get the value of the “`snap-to-ticks`” property. When overloading is enabled, this is equivalent to

    get spinButton #snapToTicks

setSpinButtonSnapToTicks :: (MonadIO m, IsSpinButton o) => o -> Bool -> m () Source #

Set the value of the “`snap-to-ticks`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #snapToTicks := value ]

## updatePolicy

Whether the spin button should update always, or only when the value is acceptable.

constructSpinButtonUpdatePolicy :: (IsSpinButton o, MonadIO m) => SpinButtonUpdatePolicy -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`update-policy`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonUpdatePolicy :: (MonadIO m, IsSpinButton o) => o -> m SpinButtonUpdatePolicy Source #

Get the value of the “`update-policy`” property. When overloading is enabled, this is equivalent to

    get spinButton #updatePolicy

setSpinButtonUpdatePolicy :: (MonadIO m, IsSpinButton o) => o -> SpinButtonUpdatePolicy -> m () Source #

Set the value of the “`update-policy`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #updatePolicy := value ]

## value

The current value.

constructSpinButtonValue :: (IsSpinButton o, MonadIO m) => Double -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`value`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonValue :: (MonadIO m, IsSpinButton o) => o -> m Double Source #

Get the value of the “`value`” property. When overloading is enabled, this is equivalent to

    get spinButton #value

setSpinButtonValue :: (MonadIO m, IsSpinButton o) => o -> Double -> m () Source #

Set the value of the “`value`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #value := value ]

## wrap

Whether a spin button should wrap upon reaching its limits.

constructSpinButtonWrap :: (IsSpinButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`wrap`” property. This is rarely needed directly, but it is used by `new`.

getSpinButtonWrap :: (MonadIO m, IsSpinButton o) => o -> m Bool Source #

Get the value of the “`wrap`” property. When overloading is enabled, this is equivalent to

    get spinButton #wrap

setSpinButtonWrap :: (MonadIO m, IsSpinButton o) => o -> Bool -> m () Source #

Set the value of the “`wrap`” property. When overloading is enabled, this is equivalent to

    set spinButton [ #wrap := value ]

# Signals

## activate

type SpinButtonActivateCallback = IO () Source #

Emitted when the spin button is activated.

The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.

If the <kbd>Enter</kbd> key results in the value being committed to the spin button, then activation does not occur until <kbd>Enter</kbd> is pressed again.

Since: 4.14

afterSpinButtonActivate :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #activate callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonActivate :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #activate callback

## changeValue

type SpinButtonChangeValueCallback Source #

Arguments

= ScrollType | `scroll`: a `GtkScrollType` to specify the speed and amount of change
-> IO () |

Emitted when the user initiates a value change.

This is a keybinding signal.

Applications should not connect to it, but may emit it with `g_signal_emit_by_name()` if they need to control the cursor programmatically.

The default bindings for this signal are Up/Down and PageUp/PageDown.

afterSpinButtonChangeValue :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonChangeValueCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changeValue signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #changeValue callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonChangeValue :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonChangeValueCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changeValue signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #changeValue callback

## input

type SpinButtonInputCallback Source #

Arguments

= IO (Int32, Double) | Returns: `True` for a successful conversion, `False` if the input was not handled, and `INPUT_ERROR` if the conversion failed.

Emitted to convert the users input into a double value.

The signal handler is expected to use `editableGetText` to retrieve the text of the spinbutton and set `newValue` to the new value.

The default conversion uses `strtod`.

afterSpinButtonInput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonInputCallback) -> m SignalHandlerId Source #

Connect a signal handler for the input signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #input callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonInput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonInputCallback) -> m SignalHandlerId Source #

Connect a signal handler for the input signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #input callback

## output

type SpinButtonOutputCallback Source #

Arguments

= IO Bool | Returns: `True` if the value has been displayed

Emitted to tweak the formatting of the value for display.

### c code

    // show leading zeros
    static gboolean
    on_output (GtkSpinButton *spin,
               gpointer       data)
    {
       char *text;
       int value;

       value = gtk_spin_button_get_value_as_int (spin);
       text = g_strdup_printf ("%02d", value);
       gtk_editable_set_text (GTK_EDITABLE (spin), text):
       g_free (text);

       return TRUE;
    }

afterSpinButtonOutput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonOutputCallback) -> m SignalHandlerId Source #

Connect a signal handler for the output signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #output callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonOutput :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonOutputCallback) -> m SignalHandlerId Source #

Connect a signal handler for the output signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #output callback

## valueChanged

type SpinButtonValueChangedCallback = IO () Source #

Emitted when the value is changed.

Also see the SpinButton::output signal.

afterSpinButtonValueChanged :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonValueChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the valueChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #valueChanged callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonValueChanged :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonValueChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the valueChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #valueChanged callback

## wrapped

type SpinButtonWrappedCallback = IO () Source #

Emitted right after the spinbutton wraps from its maximum to its minimum value or vice-versa.

afterSpinButtonWrapped :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonWrappedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wrapped signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after spinButton #wrapped callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSpinButtonWrapped :: (IsSpinButton a, MonadIO m) => a -> ((?self :: a) => SpinButtonWrappedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wrapped signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on spinButton #wrapped callback