Class SpinButton.Builder<B extends SpinButton.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, CellEditable.Builder<B>, Editable.Builder<B>, Orientable.Builder<B>, BuilderInterface
Enclosing class:
SpinButton

public static class SpinButton.Builder<B extends SpinButton.Builder<B>> extends Widget.Builder<B> implements Accessible.Builder<B>, CellEditable.Builder<B>, Editable.Builder<B>, Orientable.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public SpinButton build()
      Finish building the SpinButton object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to SpinButton.
      Overrides:
      build in class Widget.Builder<B extends SpinButton.Builder<B>>
      Returns:
      a new instance of SpinButton with the properties that were set in the Builder object.
    • setActivatesDefault

      public B setActivatesDefault(boolean activatesDefault)

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

      See Gtk.SpinButton::activate for what counts as activation.

      Parameters:
      activatesDefault - the value for the activates-default property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.14
    • setAdjustment

      public B setAdjustment(Adjustment adjustment)
      The adjustment that holds the value of the spin button.
      Parameters:
      adjustment - the value for the adjustment property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setClimbRate

      public B setClimbRate(double climbRate)
      The acceleration rate when you hold down a button or key.
      Parameters:
      climbRate - the value for the climb-rate property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setDigits

      public B setDigits(int digits)
      The number of decimal places to display.
      Parameters:
      digits - the value for the digits property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setNumeric

      public B setNumeric(boolean numeric)
      Whether non-numeric characters should be ignored.
      Parameters:
      numeric - the value for the numeric property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setSnapToTicks

      public B setSnapToTicks(boolean snapToTicks)
      Whether erroneous values are automatically changed to the spin buttons nearest step increment.
      Parameters:
      snapToTicks - the value for the snap-to-ticks property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setUpdatePolicy

      public B setUpdatePolicy(SpinButtonUpdatePolicy updatePolicy)
      Whether the spin button should update always, or only when the value is acceptable.
      Parameters:
      updatePolicy - the value for the update-policy property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setValue

      public B setValue(double value)
      The current value.
      Parameters:
      value - the value for the value property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setWrap

      public B setWrap(boolean wrap)
      Whether a spin button should wrap upon reaching its limits.
      Parameters:
      wrap - the value for the wrap property
      Returns:
      the Builder instance is returned, to allow method chaining
    • onActivate

      public B onActivate(SpinButton.ActivateCallback handler)

      Emitted when the spin button is activated.

      The keybindings for this signal are all forms of the Enter key.

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

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.14
      See Also:
    • onChangeValue

      public B onChangeValue(SpinButton.ChangeValueCallback handler)

      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.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onInput

      public B onInput(SpinButton.InputCallback handler)

      Emitted to convert the users input into a double value.

      The signal handler is expected to use Editable.getText() to retrieve the text of the spinbutton and set newValue to the new value.

      The default conversion uses g_strtod().

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onOutput

      public B onOutput(SpinButton.OutputCallback handler)

      Emitted to tweak the formatting of the value for display.

      // 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;
      }
      
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onValueChanged

      public B onValueChanged(SpinButton.ValueChangedCallback handler)

      Emitted when the value is changed.

      Also see the Gtk.SpinButton::output signal.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onWrapped

      public B onWrapped(SpinButton.WrappedCallback handler)
      Emitted right after the spinbutton wraps from its maximum to its minimum value or vice-versa.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: