The Elementary button widget is a simple push button. It is composed of a label icon and an icon object and has autorepeat feature.
Button Examples | |
---|---|
Hello, Button! | Complete Example |
//Creating a button Evas_Object *button = elm_button_add(parent);
The icon can be updated with elm_object_part_content_set()
function with the
âiconâ part name.
Evas_Object *ic; ic = elm_icon_add(button); elm_image_file_set(ic, "icon.png", NULL); elm_object_part_content_set(button, "icon", ic);
The label can be modified using the elm_object_text_set()
function.
elm_object_text_set(button, "Click me!");
Also, defined in the default theme, the button has the following styles available:
default
: a normal button.anchor
: Like default, but the button fades away when the mouse is not over it, leaving only the text or icon.hoversel_vertical
: Internally used by Hoversel to give a continuous look across its options.hoversel_vertical_entry
: Another internal for Hoversel.naviframe
: Internally used by Naviframe for its back button.colorselector
: Internally used by Colorselector for its left and right buttons.
To change the style of the button, we call the elm_object_style_set()
function
on our button object.
elm_object_style_set(button,"naviframe");
Button emits the following signals:
âclickedâ
: the user clicked the button (press/release).ârepeatedâ
: the user pressed the button without releasing it.âpressedâ
: button was pressed.âunpressedâ
: button was released after being pressed.âfocusedâ
: When the button has received focus. (since 1.8)âunfocusedâ
: When the button has lost focus. (since 1.8) In all cases, the event parameter of the callback will be NULL.
For all these signals the event_info
parameter returned in the callback is
NULL.
This is an example to register and define callback function called by the clicked signal.
evas_object_smart_callback_add(button, "clicked", _clicked_cb, data); // Callback function for the "clicked" signal // This callback is called when the button is clicked by the user static void _clicked_cb (void *data, Evas_Object *obj, void *event_info) { printf("Button clicked\n"); }
The autorepeat feature (enabled by default) consists of calling the ârepeatedâ
signal when the user keeps the button pressed. This feature can be disabled
with the elm_button_autorepeat_set()
function. The autorepeat is configured
with
elm_button_autorepeat_initial_timeout_set()
: to set the initial timeout before the autorepeat event is generatedelm_button_autorepeat_gap_timeout_set()
: to set the interval between two autorepeat eventsDisable the autorepeat feature:
elm_button_autorepeat_set(button, EINA_FALSE);
Enable the autorepeat feature (enabled by default):
elm_button_autorepeat_set(button, EINA_TRUE);
Set the initial timeout to five seconds:
elm_button_autorepeat_initial_timeout_set(button, 5.0);
Set the gap between two signals to 0.5 seconds:
elm_button_autorepeat_gap_timeout_set(button, 0.5);
Button Examples | |
---|---|
Hello, Button! | Complete Example |