Elementary flipselector widget

This code snippet demonstrates how to create a flipselector widget and perform some basic operations on it: populate it with items, flip to the next item, get the selected item label.
//define flipselector labels
static const char *colors[] = { "red", "yellow", "blue" };

static void flip_selector_test(appdata_s *ad) {
	Evas_Object *box = elm_box_add(ad->win);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
	elm_win_resize_object_add(ad->win, box);
	evas_object_show(box);

	//create a flipselector
	Evas_Object *flipselector = elm_flipselector_add(ad->win);
	evas_object_size_hint_weight_set(flipselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	//fill filpselector with items
	for (int i = 0; i < sizeof(colors) / sizeof(colors[0]); i++) {
		elm_flipselector_item_append(flipselector, colors[i], NULL, NULL);
	}

	elm_box_pack_end(box, flipselector);
	evas_object_show(flipselector);

	//flip next
	elm_flipselector_flip_next(flipselector);

	//get selected item
	Elm_Object_Item *item = elm_flipselector_selected_item_get(flipselector);
	const char* text = item ? elm_object_item_text_get(item) : "no item selected";
	dlog_print(DLOG_DEBUG, LOG_TAG, "Selected item: %s", text);
}

Responses

0 Replies