如何处理 Tizen 表盘上的触摸事件?
How to handle touch event on Tizen watchface?
我想处理表盘上的触摸事件。
我该怎么做?
我想在用户触摸手表时使用信息页面更改表盘。
您可以在表盘Window下设置回调到Elementary Object。
此资源应该对您有所帮助。参考 evas_object_event_callback_add 的用法和第一个参数。
#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);
}
"touch" (EVAS_CALLBACK_MOUSE_DOWN
) 事件句柄的快速图表:
更多详情here。
我想处理表盘上的触摸事件。 我该怎么做? 我想在用户触摸手表时使用信息页面更改表盘。
您可以在表盘Window下设置回调到Elementary Object。
此资源应该对您有所帮助。参考 evas_object_event_callback_add 的用法和第一个参数。
#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);
}
"touch" (EVAS_CALLBACK_MOUSE_DOWN
) 事件句柄的快速图表:
更多详情here。