Tizen Native: Callback set for hardware buttons are not called

349 Views Asked by At

I set the callback for hardware buttons Back and More using the code:

static void win_more_cb(void* data, Evas_Object* obj, void* event_info) {
    appdata_s* ad = data;
    if (ad->ctxpopup != NULL) evas_object_del(ad->ctxpopup);

    ad->ctxpopup = elm_ctxpopup_add(ad->win);
    elm_object_style_set(ad->ctxpopup, "more/default");

    eext_object_event_callback_add(ad->ctxpopup, EEXT_CALLBACK_BACK, _eext_ctxpopup_back_cb, NULL);
    eext_object_event_callback_add(ad->ctxpopup, EEXT_CALLBACK_MORE, _eext_ctxpopup_back_cb, NULL);
    evas_object_smart_callback_add(ad->ctxpopup, "dismissed", ctxpopup_dismissed_cb, NULL);

    elm_ctxpopup_item_append(ad->ctxpopup, "Add", NULL, ctxpopup_add_cb, NULL);

    move_more_ctxpopup(ad->ctxpopup);
    evas_object_show(ad->ctxpopup);
}

But, it's never called.

Notice: I used a specially created _eext_ctxpopup_back_cb, that writes debug log to check if it's called, instead of standard eext_ctxpopup_back_cb. I tried with eext_ctxpopup_back_cb too.

With this code, when I tap a hardware button (Back or More), it calls the callback, which was set for the main window. The _eext_ctxpopup_back_cb is never called!

Here is the code, which sets callbacks for the main window:

eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
eext_object_event_callback_add(ad->win, EEXT_CALLBACK_MORE, win_more_cb, ad);

So, it looks like eext_object_event_callback_add() does not actually set the callback for Ctxpopup or Ctxpopup does not receive EEXT_CALLBACK_BACK and EEXT_CALLBACK_MORE events for some reason.

I saw usage of eext_object_event_callback_add() with Ctxpopup in Tizen Native API documentation and in many sample applications, so I assume it should have worked, but it does not.

Please advice.

Update:

I deployed my not-yet-ready app to a Tizen device and the Back button worked there! So, this is something in the Debug environment or emulator (it does not work in emulator).

1

There are 1 best solutions below

0
On BEST ANSWER

As I wrote in "update", this happened only in emulator. On a real device (Samsung Z1) the hardware Back button worked fine with the specified code.

But, I managed to fix this for emulator too:

I figured out that the EEXT_CALLBACK_BACK is not called for a ctxpopup (as well as for naviframe, that I added later), if any of the hardware callbacks (EEXT_CALLBACK_BACK or EEXT_CALLBACK_MORE) is registered for the main window (ad->win). As soon as I moved EEXT_CALLBACK_MORE to a naviframe, the hardware Back button started to work in emulator as well.

So, generally, it looks like these two callbacks should not ever be set for the main window. If they are, child components do not receive hardware Back and More events.