On Mon, May 31, 2010 at 7:17 PM, Andreas Volz <li...@brachttal.net> wrote: > Hello, > > I've a question about: > > EAPI void > evas_object_smart_callback_add(Evas_Object *obj, const char *event, > void (*func) (void *data, Evas_Object *obj, void *event_info), const > void *data) > > Why is event_info a void* data type and not some type of struct? To > which struct should I cast it to do something useful with it? > > There is: > > typedef struct _Evas_Event_Mouse_Down Evas_Event_Mouse_Down; /**< Event > structure for #EVAS_CALLBACK_MOUSE_DOWN event callbacks */ > typedef struct _Evas_Event_Mouse_Up Evas_Event_Mouse_Up; /**< Event > structure for #EVAS_CALLBACK_MOUSE_UP event callbacks */ > ... > > in Evas.h. But how do I know this by object_smart_callback_add? Normal I don't > know it if I don't call evas_object_smart_callback_call() from my own code.
You don't, you need to know which function/event type you added to know what type you get. In python, where we need to actually convert to an object, we must do it. In C++, you can just leave it to the user, or do as we do. It is something like: if type == EVAS_CALLBACK_MOUSE_DOWN, then internal_cb = my_func_that_converts_to_mouse_down internal_data = (this=this, cb=user_cb, data=user_data) else ... evas_object_event_callback_add(this->obj, type, internal_cb, internal_data) void my_func_that_converts_to_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info) { Evas_Event_Mouse_Down *ev = event_info; internal_data = data; internal_data->cb(internal_data->data, internal_data->this, convert_to_cxx(ev)); } boring, but it is C... so :-/ BR, -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: barbi...@gmail.com Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel