State pointer for check widget
This code snippet demonstrates how to create and use state pointer for elementary check widget.
static void check_changed_cb(void *data, Evas_Object *obj, void *event_info) {
//here we use check's state pointer passed in data
if (*(Eina_Bool *) data) {
dlog_print(DLOG_DEBUG, LOG_TAG, "checked");
} else {
dlog_print(DLOG_DEBUG, LOG_TAG, "unchecked");
}
}
static void check_test(Evas_Object *parent) {
//create a check
Evas_Object *check = elm_check_add(parent);
evas_object_move(check, 0, 50);
evas_object_resize(check, 200, 30);
elm_object_style_set(check, "popup");
elm_object_text_set(check, "Label");
//create an Eina_Bool variable for storing check's state
Eina_Bool value;
//connect this variable with the actual check's state
elm_check_state_pointer_set(check, &value);
//now you can use it in check's change callback
evas_object_smart_callback_add(check, "changed", check_changed_cb, &value);
//Check's state pointer can only be used for read operations. To change the state you have to use this function:
elm_check_state_set(check, EINA_TRUE);
evas_object_show(check);
}