Tizen Native API  5.5
Toolbar Example - Items with Menus

Toolbar widgets have support to items with menus. This kind of item will display a menu when selected by the user.

Let's start populating a toolbar with some regular items, the same way we started Toolbar Example 2.

   tb = elm_toolbar_add(win);
   evas_object_size_hint_weight_set(tb, 0.0, 0.0);
   evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
   evas_object_show(tb);

   elm_toolbar_item_append(tb, "document-print", "Print", NULL, NULL);
   elm_toolbar_item_append(tb, "folder-new", "Folder", NULL, NULL);
   elm_toolbar_item_append(tb, "clock", "Clock", NULL, NULL);
   elm_toolbar_item_append(tb, "refresh", "Update", NULL, NULL);

The only difference is that we'll keep the default shrink mode, that adds an item with a menu of hidden items.

So, a important thing to do is to set a parent for toolbar menus, or they will use the toolbar as parent, and its size will be restricted to that.

   elm_toolbar_menu_parent_set(tb, win);

Not only items' menus will respect this parent, but also the own toolbar menu, used to show hidden items.

Next, let's add an item set to display a menu:

   tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail", NULL, NULL);
   elm_toolbar_item_menu_set(tb_it, EINA_TRUE);

Now, to add two options to this item, we can get the menu object and use it as a regular elm_menu. See Menu example for more about menu widget.

   menu = elm_toolbar_item_menu_get(tb_it);
   elm_menu_item_add(menu, NULL, "emptytrash", "Empty Trash", NULL, NULL);
   elm_menu_item_add(menu, NULL, "trashcan_full", "Full Trash", NULL, NULL);

See toolbar_example_03.c, whose window should look like this picture:

toolbar_example_03.png