Segmentcontrol
This feature is supported in mobile applications only.
This UI component consists of several segment items. A segment item is similar to a discrete two state button. Any time, only one segment item can be selected. A segment item is composed of a label (text) and an icon.
This UI component inherits from the layout component, so all the layout components API can be used on segmentcontrol objects.
Figure: Segmentcontrol with text
Figure: Segmentcontrol with icons
Figure: Segmentcontrol hierarchy
Adding a Segmentcontrol Component
The following example shows how to add a segmentcontrol component.
Evas_Object *segcontrol, *parent; segcontrol = elm_segment_control_add(parent);
Adding Items
You can add items to the UI component. In the following example four items containing only text labels (no icons) are added.
Elm_Object_Item *it; elm_segment_control_item_add(segcontrol, NULL, "item1"); elm_segment_control_item_add(segcontrol, NULL, "item2"); elm_segment_control_item_add(segcontrol, NULL, "item3"); it = elm_segment_control_item_add(segcontrol, NULL, "item4");
You can also:
- Insert an item at a specific position starting at 0.
elm_segment_control_item_insert_at(segcontrol, NULL, "item7", 2);
- Delete an item.
elm_segment_control_item_del_at(segcontrol, 2);
- Set the selected state of an item manually.
elm_segment_control_item_selected_set(it, EINA_TRUE);
- Disable the whole segment control.
elm_object_disabled_set(segcontrol, EINA_TRUE);
Using the Segmentcontrol Callbacks
This is how to register a callback on the changedsignal. It is called when the user clicks on a segment item which is not previously selected. The event_info parameter is the segment item pointer.
{ evas_object_smart_callback_add(segcontrol, "changed", changed_cb, data); } // Callback function for the "changed" signal // This callback is called when the segcontrol selected item changes void changed_cb(void *data, Evas_Object *obj, void *event_info) { Elm_Segment_Item *it = event_info; dlog_print(DLOG_INFO, LOG_TAG, "The selected segment item has changed\n"); }