tizen如何使用基本ctxpopup小部件的代码
这个代码片段演示了如何使用基本ctxpopup小部件。static void ctxpopup_item_cb(void *data, Evas_Object *obj, void *event_info) {
printf("item selected: %s\n", elm_object_item_text_get(event_info));
}
static void dismissed_cb(void *data, Evas_Object *obj, void *event_info) {
evas_object_del(obj);
}
static void show_ctx_popup(void *data, Evas_Object *obj, void *event_info) {
appdata_s *ad = (appdata_s *) data;
Evas_Object *ctxpopup = elm_ctxpopup_add(ad->win);
elm_object_style_set(ctxpopup, "dropdown/list");
eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
evas_object_smart_callback_add(ctxpopup, "dismissed", dismissed_cb, NULL);
//add list of 3 items
elm_ctxpopup_item_append(ctxpopup, "Item 1", NULL, ctxpopup_item_cb, NULL);
elm_ctxpopup_item_append(ctxpopup, "Item 2", NULL, ctxpopup_item_cb, NULL);
elm_ctxpopup_item_append(ctxpopup, "Item 3", NULL, ctxpopup_item_cb, NULL);
elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN,
ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN);
//change position
Evas_Coord x, y;
evas_pointer_canvas_xy_get(evas_object_evas_get(ad->win), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void ctx_popup_test(appdata_s *ad) {
Evas_Object *button;
button = elm_button_add(ad->win);
elm_object_text_set(button, "Show ctx popup");
evas_object_smart_callback_add(button, "clicked", show_ctx_popup, ad);
evas_object_resize(button, 480, 100);
evas_object_show(button);
}
页:
[1]