The check widget is similar to the radio widget, except that it does not work as a group. It toggles the value of a boolean between true and false.
This widget inherits from the layout widget. All layout functions can be used on the check widget.
This is how to create a check widget.
Evas_Object *check; check = elm_check_add(parent);
Check widget style can be set with the elm_object_style_set()
function. The
following styles are available:
âdefaultâ
âtoggleâ
elm_object_style_get()
allows to get the current style.
After having created a check object, it is possible to set its boolean value
to EINA_TRUE
.
elm_check_state_set(check, EINA_TRUE);
We can also retrieve the current value of the check object.
Eina_Bool value = elm_check_state_get(check);
As with the radio object, an icon and a label can be set.
Default content parts of the check widget that you can use for are:
âiconâ
- An icon of the checkDefault text parts of the check widget that you can use for are:
âdefaultâ
- A label of the checkâonâ
- On state label of the check (only valid for âtoggleâ style.)âoffâ
- Off state label of the check (only valid for âtoggleâ style.)// Create a Home icon Evas_Object *icon; icon = elm_icon_add(parent); elm_icon_standard_set(icon, "home"); // Set it to the check object elm_object_part_content_set(check, "icon", icon); // Set the check label elm_object_text_set(check, "Check label");
We can also modify the âonâ and âoffâ labels (only valid for 'âtoggleâ style).
elm_object_part_text_set(check, "on", "True"); elm_object_part_text_set(check, "off", "False");
The get functions of the elementary object API can be used to retrieve the content set to the check object.
// Get the current set text of the check label char *text = elm_object_text_get(check); // Get the content set in the icon part Evas_Object *icon = elm_object_part_content_get(check, "icon");
This widget emits the following signals, besides the ones sent from Layout:
âchangedâ
- This is called whenever the user changes the state of the check objects (event_info is always NULL).âfocusedâ
- When the check has received focus. (since 1.8)âunfocusedâ
- When the check has lost focus. (since 1.8)âlanguage,changedâ
- the program's language changed (since 1.9)
When the value is changed by the user, the changed
signal is emitted.
event_info
parameter is NULL
.
This example shows how to register a callback on this signal.
evas_object_smart_callback_add(check, "changed", _changed_cb, data); // Callback function for the "changed" signal // This callback is called when the check value changes static void _changed_cb(void *data, Evas_Object *obj, void *event_info) { printf("The value has changed\n"); }