~~Title: Ctxpopup Widget PG~~
{{page>widgets_index}}
----
===== Ctxpopup Widgets =====
{{ :widgets_ctxpopup_tree.png }}{{ :widgets_ctxpopup.png }}
Ctxpopup is a contextual popup, which can show a list of items.
=== Table of Contents ===
* [[#Adding_a_Ctxpopup|Adding a Ctxpopup]]
* [[#Configuring_Ctxpopup|Configuring Ctxpopup]]
* [[#Managing_Ctxpopup_Items|Managing Ctxpopup Items]]
* [[#Using_Ctxpopup_Callbacks|Using Ctxpopup Callbacks]]
=== Related Info ===
* [[https://build.enlightenment.org/job/nightly_elm_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/group__Ctxpopup.html|Ctxpopup Widget API]]
* [[https://build.enlightenment.org/job/nightly_elm_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/tutorial_ctxpopup.html|A Ctxpopup Example]]
==== Adding a Ctxpopup ====
A ctxpopup can be created with ''elm_ctxpopup_add()'' and when shown, it
automatically chooses an area inside its parent object's view (set via
''elm_ctxpopup_hover_parent_set()'') to optimally fit into it.
Evas_Object *ctxpopup = elm_ctxpopup_add(parent);
==== Configuring Ctxpopup ====
The context popup orientation can be set with
''elm_ctxpopup_horizontal_set()''. Here we set it to horizontal.
elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
We can also disable auto hiding if we want the ctxpopup never to be hidden.
(Auto hide is enabled by default.)
elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
==== Managing Ctxpopup Items ====
The ctxpopup can contain a small number of items. Each of them can have a
label and an icon. Here we append an item with the "Test" label and no icon.
Elm_Object_Item *it = elm_ctxpopup_item_append(ctxpopup, "test", NULL, _ctxpopup_item_cb, NULL);
The ''_ctxpopup_item_cb()'' callback will be called when the item is clicked. This
is how to write the definition of this callback.
static void
_ctxpopup_item_cb(void *data, Evas_Object *obj, void *event_info)
{
printf("ctxpopup item selected\n");
}
Then the item label is set to "New label".
elm_object_item_part_text_set(it, "default", "New label");
And its icon is modified to the standard "home" icon.
Evas_Object *home_icon = elm_icon_add(ctxpopup);
elm_icon_standard_set(home_icon, "home");
elm_object_item_part_content_set(it, "icon", home_icon);
==== Using Ctxpopup Callbacks ====
The context popup emits the "dismissed" signal when it is dismissed. We can
register a callback to this signal. The event_info parameter is NULL.
evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, data);
static void
_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
{
printf("ctxpopup dismissed\n");
}
\\
//**__[[https://build.enlightenment.org/job/nightly_elm_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/tutorial_ctxpopup.html|A Ctxpopup Example]]__**//
\\
----
{{page>widgets_index}}