Gengrid longpresssed options
This code snippet shows how to use and customize the 'longpressed' event in a gengrid.
//return home icon
static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part) {
Evas_Object *icon = elm_icon_add(obj);
elm_icon_standard_set(icon, "home");
evas_object_show(icon);
return icon;
}
//longpressed event callback
static void _long_press(void *data, Evas_Object *obj, void *event_info) {
dlog_print(DLOG_INFO, LOG_TAG, "Long press on: %p", event_info);
}
static void gengrid_test(Evas_Object *parent) {
Evas_Object *grid = elm_gengrid_add(parent);
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(parent, grid);
evas_object_show(grid);
elm_gengrid_horizontal_set(grid, EINA_TRUE);
elm_gengrid_item_size_set(grid, 150, 150);
Elm_Gengrid_Item_Class *gic;
gic = elm_gengrid_item_class_new();
gic->item_style = "default";
gic->func.content_get = _item_content_get;
for (int i = 0; i < 20; i++) {
elm_gengrid_item_append(grid, gic, NULL, NULL, NULL);
}
//set callback for longpressed event
evas_object_smart_callback_add(grid, "longpressed", _long_press, NULL);
//change longpressed timeout (if 'longpressed' occurs there will be no 'clicked' event)
elm_gengrid_longpress_timeout_set(grid, 2);
}