Languages

Menu
Sites
Language
EFL toolbar bug

Hi, All

I am create a EFL toolbar widget, as below:

static Evas_Object*
create_toolbar(appdata_s *ad)
{
    Evas_Object *tabbar;

 tabbar = elm_toolbar_add(ad->conform);
 elm_object_style_set(tabbar, "tabbar");
 elm_toolbar_shrink_mode_set(tabbar, ELM_TOOLBAR_SHRINK_NONE);
 elm_toolbar_transverse_expanded_set(tabbar, EINA_TRUE);

 elm_toolbar_item_append(tabbar, NULL, "Message", tabbar_item_cb, ad);
 elm_toolbar_item_append(tabbar, NULL, "Friends", tabbar_item_cb, ad);
 elm_toolbar_item_append(tabbar, NULL, "About Me", tabbar_item_cb, ad);

 return tabbar;
}

The style of selected item has an underline, but if I re-click on the same item, the underline will lose, and third time click on it, the underline will back. As below screenshot, the first pic is the result of first click, the second pic is the result of second click, and the third time click on it, the will same with the first pic.

       

 

 

Edited by: colin Rao on 26 Jan, 2015

Responses

7 Replies
colin Rao
    ad->tabbar = create_toolbar(ad);
	elm_toolbar_select_mode_set(ad->tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS);

This issue can be fixed by call elm_toolbar_select_mode_set(ad->tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS). But it will cause a new issue, that's the toolbar item select callback function will be called every click even it already been selected. To resolve this new issue, I just use a stupid manner, use a global var to trace the current selected item, so the item select callback function will just be called at the first click.

Also, elm_toolbar_select_mode_set should be called after elm_toolbar_item_append.

colin Rao

another issue, while call elm_toolbar_select_mode_set(ad->tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS), it will call the item selected callback right now with the first tabbar item by default. 

I think the function elm_toolbar_select_mode_set shouldn't call the callback right now, it's just a confige function of toolbar. 

Alex Ashirov

Hi,

Indeed, this looks like a bug. As a workaround you can register the callback after the elm_toolbar_select_mode_set()  call.

colin Rao

Hi Alex, thanks!

But I've ever do the testing, as the code, I call the elm_toolbar_select_mode_set() before the callback register, but the function tabbar_item_cb will be called after the first item append to the toolbar, it will be called after elm_toolbar_item_append(tabbar, NULL, TXT_TABBAR_ITEM_MSG, ad) executed. I think this is an API bug.

static Evas_Object*
create_toolbar(appdata_s *ad)
{
    Evas_Object *tabbar;

	tabbar = elm_toolbar_add(ad->conform);
	elm_object_style_set(tabbar, "tabbar");
	elm_toolbar_shrink_mode_set(tabbar, ELM_TOOLBAR_SHRINK_NONE);
	elm_toolbar_transverse_expanded_set(tabbar, EINA_TRUE);
	elm_toolbar_select_mode_set(tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS);

	elm_toolbar_item_append(tabbar, NULL, TXT_TABBAR_ITEM_MSG, tabbar_item_cb, ad);
	elm_toolbar_item_append(tabbar, NULL, TXT_TABBAR_ITEM_CAT, tabbar_item_cb, ad);
	elm_toolbar_item_append(tabbar, NULL, TXT_TABBAR_ITEM_ME, tabbar_item_cb, ad);

	return tabbar;
}

 

colin Rao

actually, it's call the tabbar_item_cb before the first item appended to the tabbar. because of, in the callback function cant get the txt value. as below code, the str is empty.

    Elm_Object_Item *it = (Elm_Object_Item*) event_info;
    const char *str = elm_object_item_text_get(it);

 

Alex Ashirov

Hi,

Can you please try the following:

void tabbar_item_cb(void *data, Evas_Object *obj, void *event_info)
{
        const char *str;
        Elm_Object_Item *it = elm_toolbar_selected_item_get(obj);
        if (it) {
                str = elm_object_item_text_get(it);

       }

colin Rao

Hi, I've tested your code, Elm_Object_Item *it is not null, but the str is still empty.