vittochan
vittochan

Reputation: 685

How to handle touch event on Tizen watchface?

I'd like to handle the touch event on a watch face. How can I do it? I want to change the watch face with a info page when the user touch the watch.

Upvotes: 2

Views: 621

Answers (2)

Andrii Omelchenko
Andrii Omelchenko

Reputation: 13343

Quick diagram for "touch" (EVAS_CALLBACK_MOUSE_DOWN) event handle: enter image description here

More details here.

Upvotes: 1

pius lee
pius lee

Reputation: 1174

You can set the callback to Elementary Object under Watchface Window.

This source should help you. refer usage of evas_object_event_callback_add and there first argument.

#include <sstream>
#include <watch_app.h>
#include <watch_app_efl.h>
#include <Elementary.h>

static int Count;

static bool app_create(int width, int height, void *data)
{
    Evas_Object *win;
    watch_app_get_elm_win(&win);
    evas_object_resize(win, width, height);

    Evas_Object *conform = elm_conformant_add(win);
    elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
    elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE);
    evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(win, conform);
    evas_object_show(conform);

    Evas_Object *box = elm_box_add(conform);
    evas_object_show(box);
    elm_object_content_set(conform, box);

    Evas_Object *label = elm_label_add(box);
    elm_object_text_set(label, "<align=center>0</align>");
    elm_box_pack_end(box, label);
    evas_object_show(label);

    auto on_touch_up = [](void* data, Evas *e, Evas_Object *obj, void *event_info)
    {
        Evas_Object* label = static_cast<Evas_Object*>(data);
        std::ostringstream ss;
        ss << "<align=center>" << Count++ << "</align>";
        elm_object_text_set(label, ss.str().c_str());
    };

    evas_object_event_callback_add(conform, EVAS_CALLBACK_MOUSE_DOWN, on_touch_up, label);

    evas_object_show(win);
    return true;
}


int main(int argc, char *argv[])
{
    watch_app_lifecycle_callback_s event_callback = {
            app_create, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
    };
    return watch_app_main(argc, argv, &event_callback, nullptr);
}

Upvotes: 3

Related Questions