Mobile native

Spinner

This feature is supported in mobile applications only.

The spinner component increases or decreases a numeric value with the arrow buttons.

This UI component inherits from the layout component, so all functions concerning the layout component are used on the spinner component.

Figure: Spinner component

Spinner component

Figure: Spinner hierarchy

Spinner hierarchy

Adding a Spinner Component

The following example shows how to create a spinner object.

Evas_Object *spin, *parent;

spin = elm_spinner_add(parent);

Configuring the Spinner

The label format is set to a different value:

elm_spinner_label_format_set(spin, "%1.2f meters");

You can determine the result of clicking the arrow buttons. In this example, a click on an arrow increases or decreases with 2.0 units:

elm_spinner_step_set(spin, 2.0);

The wrapping mode is activated. In this mode, the spinner wraps when it reaches its minimum or maximum value.

elm_spinner_wrap_set(spin, EINA_TRUE);

You can set the minimum and maximum values of the spinner.

elm_spinner_min_max_set(spin, -25.0, 100.0);

The spinner object can be set vertical, and the change interval when the user presses the arrows long can be modified so that it changes faster.

elm_object_style_set(spin, "vertical");
elm_spinner_interval_set(spin, 0.1);

If the user has to select between text values instead of numerical values, it is possible to add our own text labels. Here spin2 object shows three numbers written in text characters.

Evas_Object *spin2 = elm_spinner_add(parent);
elm_spinner_min_max_set(spin2, 1, 3);
elm_spinner_special_value_add(spin2, 1, "One");
elm_spinner_special_value_add(spin2, 2, "Two");
elm_spinner_special_value_add(spin2, 3, "Three");

Using the Spinner Callbacks

This UI component emits the following signals:

  • changed: The spinner value changes.
  • delay,changed: A short time after the user changes the value. This is called only when the user stops dragging for a very short period or releases the finger or mouse, so that it avoids possibly expensive reactions to the value change.

The following example shows how to register a callback on the delay,changed signal.

{
   evas_object_smart_callback_add(spin, "delay,changed", delay_changed_cb, data);
}

// Callback function for the "delay,changed" signal
// This callback is called a short time after the spinner value changes
void delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
   dlog_print(DLOG_INFO, LOG_TAG, "The spinner value has changed\n");
}
Go to top