The popup widget shows a popup area that may contain
The optional title area may contain an icon and text, the action area may contain up to three buttons.
This is how to create a popup widget.
Evas_Object *popup = elm_popup_add(parent);
elm_object_style_set(popup, "toast");
We configure the title area. We set the icon object using the part name âtitle,iconâ. We set the title text to âTest popupâ using the partname âtitle,textâ.
Evas_Object *icon; // Adding an icon to the title area elm_object_part_content_set(popup, "title,icon", icon); // Setting the title text elm_object_part_text_set(popup, "title,text", "Test popup");
We set the content of the popup. It can be a simple text
or an Evas object.
elm_object_part_text_set(popup, "default", "Test popup");
Evas_Object *content; elm_object_content_set(popup, content);
We set the buttons of the action area by creating an âOKâ button, a âCancelâ button and a âHelpâ button.
Evas_Object *button1, *button2, *button3; // Create the three buttons button1 = elm_button_add(popup); elm_object_text_set(button1, "OK"); button2 = elm_button_add(popup); elm_object_text_set(button2, "Cancel"); button3 = elm_button_add(popup); elm_object_text_set(button3, "Help"); // Set the buttons to the action area elm_object_part_content_set(popup, "button1", button1); elm_object_part_content_set(popup, "button2", button2); elm_object_part_content_set(popup, "button3", button3);
This widget emits the following signals, besides the ones sent from Layout:
âtimeoutâ
- whenever popup is closed as a result of timeout.âblock,clickedâ
- whenever user taps on Blocked Event area.âfocusedâ
- When the popup has received focus. (since 1.8)âunfocusedâ
- When the popup has lost focus. (since 1.8)âlanguage,changedâ
- the program's language changed (since 1.8)âitem,focusedâ
- When the popup item has recieved focus. (since 1.10)âitem,unfocusedâ
- When the popup item has lost focus. (since 1.10)
elm_popup_timeout_set()
is used to hide the popup after a certain time. In
this example, we set the timeout to five seconds.
elm_popup_timeout_set(popup, 5.0);
When the timeout expires, the âtimeoutâ signal is sent to the user.
evas_object_smart_callback_add(popup, "timeout", _timeout_cb, data);
static void _timeout_cb(void *data, Evas_Object *obj, void *event_info) { printf("Timeout \n"); }
The visible region of the popup is surrounded by a translucent region called Blocked Event area. By clicking on this area, the signal âblock,clickedâ is sent to the application.
Popup Examples | ||
---|---|---|
A First Example | A Second Example | A Third Example |