Mobile native

[UI Sample] Evas Event Sample Overview

The Evas Event sample demonstrates how to resister a callback function on Evas or an Evas_Object for a specific event.

The following figure illustrates the main screen and log of the Evas Event.

Figure: Evas Event screen and log

Evas Event screen and log

Evas Event screen and log

Implementation

The following code snippet demonstrates how to register the _render_flush_cb() function as a callback on an Evas for a given canvas event (EVAS_CALLBACK_RENDER_FLUSH_PRE) using the evas_event_callback_add() function.

Evas *evas = evas_object_evas_get(ad->win);

evas_event_callback_add(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _render_flush_cb, NULL); 

The following code snippet demonstrates how to register the _on_mousedown() callback on an Evas_Object for a given Evas_Object event (EVAS_CALLBACK_MOUSE_DOWN) using the evas_object_event_callback_add() function.

Evas_Object *rect  = evas_object_rectangle_add(evas);
evas_object_color_set(rect, 0, 255, 0, 255);
evas_object_move(rect, 0, 0);
evas_object_resize(rect, 300, 300);
evas_object_show(rect);

evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_mousedown, NULL);

The following code snippet defines the callback functions to be called.

static void
_render_flush_cb(void *data, Evas *e,  void *event_info)
{
   dlog_print(DLOG_DEBUG, "event", "Canvas is about to flush its rendering pipeline!");
}

static void
_on_mousedown(void *data,  Evas *evas, Evas_Object *obj,  void *event_info)
{
   dlog_print(DLOG_DEBUG, LOG_TAG, "We've got mouse_down");
}
Go to top