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.
Asked
Active
Viewed 609 times
2
-
You may try to implement in your application to recognize and react to touch gesture(e.g. tap). https://developer.tizen.org/ko/development/guides/native-application/user-interface/efl/ui-component-infrastructure-modules/handling-touch-gestures?langswitch=ko – Yasin shihab Aug 22 '16 at 05:48
-
Is it native or a webview ? – Ta-Zvi Aug 23 '16 at 11:06
2 Answers
3
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);
}

pius lee
- 1,164
- 1
- 12
- 28
1
Quick diagram for "touch" (EVAS_CALLBACK_MOUSE_DOWN
) event handle:
More details here.

Andrii Omelchenko
- 13,183
- 12
- 43
- 79