Notify
PUBLISHED
The notify UI component displays a container in a particular region of the parent object. It can receive some content, and become automatically hidden after a certain amount of time. The popup [1] component is very similar to the notify component, but supports many common layouts. For more information, see the Notify [2] API.
This feature is supported in mobile applications only.
Basic Usage
To use a notify component in your application:
- Add a notify component with the
elm_notify_add()
function:Evas_Object *notify; notify = elm_notify_add(parent);
- Fill the layout:
- Add an object to fill the layout:
Evas_Object *label = elm_label_add(parent);
- Set an object to the notify component with the
elm_object_content_set()
function:
elm_object_content_set(notify, label);
- Add an object to fill the layout:
- Register the callback functions.
The following example shows how to define and register a callback for the
timeout
signal:evas_object_smart_callback_add(notify, "timeout", timeout_cb, data); void timeout_cb(void *data, Evas_Object *obj, void *event_info) { dlog_print(DLOG_INFO, LOG_TAG, "Notify timeout"); }
The following example shows a simple use case of the notify component.
Example: Notify use case
Evas_Object *win; Evas_Object *conf; Evas_Object *notify; Evas_Object *label; /* Starting right after the basic EFL UI layout code [3] */ /* (win - conformant) */ /* Add a notify component to contain a label to the conformant */ notify = elm_notify_add(conf); elm_notify_align_set(notify, ELM_NOTIFY_ALIGN_FILL, 1.0); elm_notify_timeout_set(notify, 5.0); /* Add a label to notify */ label = elm_label_add(notify); elm_object_test_set(label, "A label in notify"); evas_object_show(label); elm_object_content_set(notify, label); evas_object_show(notify); |
Features
You can use the align and timeout features with the notify component:
- Align
Using the
elm_notify_align_set()
function, you can set the notify component alignment.The second and third parameters have a value between 0.0 and 1.0, meaning the alignment of the notify component's position within the parent window. The
ELM_NOTIFY_ALIGN_FILL
value can be used to fill the notify component in each axis direction.To align the notify object to the bottom center of the parent object:
elm_notify_align_set(notify, 0.5, 1.0);
- Timeout
The notify component can set a timeout interval, after which the notify component is hidden.
To set the timeout interval to 5 seconds:
elm_notify_timeout_set(notify, 5.0);
Callbacks
You can register callback functions connected to the following signals for a notify object.
Table: Notify callback signals
Signal | Description | event_info |
---|---|---|
timeout |
The timeout count ends and the notify component is hidden. | NULL |
block,clicked |
The user clicks outside the notify component. | NULL |