Tizen Native API
5.0
|
Objects generate events when they are moved, resized, when their visibility change, when they are deleted and so on. These methods allow one to be notified about and to handle such events.
Objects also generate events on input (keyboard and mouse), if they accept them (are visible, focused, etc).
For each of those events, Evas provides a way for one to register callback functions to be issued just after they happen.
The following figure illustrates some Evas (event) callbacks:
These events have their values in the Evas_Callback_Type enumeration, which has also ones happening on the canvas level (see Canvas Events ).
Examples on this group of functions can be found here and here.
void evas_object_event_callback_add | ( | Evas_Object * | obj, |
Evas_Callback_Type | type, | ||
Evas_Object_Event_Cb | func, | ||
const void * | data | ||
) |
Add (register) a callback function to a given Evas object event.
obj | Object to attach a callback to |
type | The type of event that will trigger the callback |
func | The function to be called when the event is triggered |
data | The data pointer to be passed to func |
This function adds a function callback to an object when the event of type type
occurs on object obj
. The function is func
.
In the event of a memory allocation error during addition of the callback to the object, evas_alloc_error() should be used to determine the nature of the error, if any, and the program should sensibly try and recover.
A callback function must have the ::Evas_Object_Event_Cb prototype definition. The first parameter (data
) in this definition will have the same value passed to evas_object_event_callback_add() as the data
parameter, at runtime. The second parameter e
is the canvas pointer on which the event occurred. The third parameter is a pointer to the object on which event occurred. Finally, the fourth parameter event_info
is a pointer to a data structure that may or may not be passed to the callback, depending on the event type that triggered the callback. This is so because some events don't carry extra context with them, but others do.
The event type type
to trigger the function may be one of #EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_AXIS_UPDATE, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_FREE, EVAS_CALLBACK_KEY_DOWN, EVAS_CALLBACK_KEY_UP, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_SHOW, EVAS_CALLBACK_HIDE, EVAS_CALLBACK_MOVE, EVAS_CALLBACK_RESIZE, EVAS_CALLBACK_RESTACK, EVAS_CALLBACK_DEL, EVAS_CALLBACK_HOLD, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_CALLBACK_IMAGE_PRELOADED or EVAS_CALLBACK_IMAGE_UNLOADED.
This determines the kind of event that will trigger the callback. What follows is a list explaining better the nature of each type of event, along with their associated event_info
pointers:
event_info
is a pointer to an #Evas_Event_Mouse_In structobj
. This may occur by the mouse pointer being moved by evas_event_feed_mouse_move() calls, or by the object being shown, raised, moved, resized, or other objects being moved out of the way, hidden or lowered, whatever may cause the mouse pointer to get on top of obj
, having been on top of another object previously.event_info
is a pointer to an #Evas_Event_Mouse_Out structevent_info
is a pointer to an #Evas_Event_Mouse_Down structevent_info
is a pointer to an #Evas_Event_Mouse_Up structevent_info
is a pointer to an #Evas_Event_Mouse_Move structevent_info
is a pointer to an #Evas_Event_Mouse_Wheel structevent_info
is a pointer to an #Evas_Event_Multi_Down structevent_info
is a pointer to an #Evas_Event_Multi_Up structevent_info
is a pointer to an #Evas_Event_Multi_Move structevent_info
is a pointer to an #Evas_Event_Axis_Update structevent_info
is NULL
event_info
is a pointer to an #Evas_Event_Key_Down structevent_info
is a pointer to an #Evas_Event_Key_Up struct event_info
is NULL
event_info
is NULL
event_info
is NULL
event_info
is NULL
event_info
is NULL
event_info
is NULL
event_info
is NULL
event_info
is NULL
.event_info
is a pointer to an #Evas_Event_Hold structevent_info
is NULL
.event_info
is NULL
.event_info
is NULL
.Example:
evas_object_event_callback_add( d.bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL); if (evas_alloc_error() != EVAS_ALLOC_ERROR_NONE) { fprintf(stderr, "ERROR: Callback registering failed! Aborting.\n"); goto panic; }
See the full example here.
void* evas_object_event_callback_del | ( | Evas_Object * | obj, |
Evas_Callback_Type | type, | ||
Evas_Object_Event_Cb | func | ||
) |
Delete a callback function from an object
obj | Object to remove a callback from |
type | The type of event that was triggering the callback |
func | The function that was to be called when the event was triggered |
This function removes the most recently added callback from the object obj
which was triggered by the event type type
and was calling the function func
when triggered. If the removal is successful it will also return the data pointer that was passed to evas_object_event_callback_add() when the callback was added to the object. If not successful NULL
will be returned.
Example:
extern Evas_Object *object; void *my_data; void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info); my_data = evas_object_event_callback_del(object, EVAS_CALLBACK_MOUSE_UP, up_callback);
void* evas_object_event_callback_del_full | ( | Evas_Object * | obj, |
Evas_Callback_Type | type, | ||
Evas_Object_Event_Cb | func, | ||
const void * | data | ||
) |
Delete (unregister) a callback function registered to a given Evas object event.
obj | Object to remove a callback from |
type | The type of event that was triggering the callback |
func | The function that was to be called when the event was triggered |
data | The data pointer that was to be passed to the callback |
This function removes the most recently added callback from the object obj
, which was triggered by the event type type
and was calling the function func
with data data
, when triggered. If the removal is successful it will also return the data pointer that was passed to evas_object_event_callback_add() (that will be the same as the parameter) when the callback was added to the object. In errors, NULL
will be returned.
Example:
extern Evas_Object *object; void *my_data; void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info); my_data = evas_object_event_callback_del_full(object, EVAS_CALLBACK_MOUSE_UP, up_callback, data);
void evas_object_event_callback_priority_add | ( | Evas_Object * | obj, |
Evas_Callback_Type | type, | ||
Evas_Callback_Priority | priority, | ||
Evas_Object_Event_Cb | func, | ||
const void * | data | ||
) |
Add (register) a callback function to a given Evas object event with a non-default priority set. Except for the priority field, it's exactly the same as evas_object_event_callback_add
obj | Object to attach a callback to |
type | The type of event that will trigger the callback |
priority | The priority of the callback, lower values called first. |
func | The function to be called when the event is triggered |
data | The data pointer to be passed to func |