Mobile native

Check

This feature is supported in mobile applications only.

The check component is similar to the radio component, except that it does not work as a group. It toggles the value of a boolean between true and false.

This UI component inherits from the layout component. All layout functions can be used on the check component.

Figure: Check component

Check component

Figure: Check hierarchy

Check hierarchy

Adding a Check Component

The following example shows how to create a check component.

Evas_Object *check, *parent;
check = elm_check_add(parent);

Modifying the Check Styles

The check component style can be set with the elm_object_style_set() function. The following styles are available:

  • default
  • favorite
  • on and off

The following example sets the favorite style on our check object.

elm_object_style_set(check, "favorite");

To get the current style, use the elm_object_style_get() function.

char *style = elm_object_style_get(check);

Using the Check Component

After having created a check object, it is possible to set its boolean value to EINA_TRUE.

elm_check_state_set(check, EINA_TRUE);

You can also retrieve the current value of the check object.

Eina_Bool value = elm_check_state_get(check);

As with a radio object, an icon and a label can be set.

// 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");

You can also modify the on and off labels.

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");

Using the Check Callbacks

When the value is changed by the user, the changed signal is emitted. The event_info parameter is NULL.

The following 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
void changed_cb(void *data, Evas_Object *obj, void *event_info)
{
   dlog_print(DLOG_INFO, LOG_TAG, "The value has changed\n");
}
Go to top