Hi,

I'm trying to reset some global state once an object loses its focus and
set a different one, when another one is clicked.

Let's assume the focuse switches from obj A to B via mouse click. The
problem is, that the "unfocused" callback of A is called _after_ object B's
"mouse clicked" callback.
This behavoir is imo - at least - contraintuitive, because the temporal
sequence is perceived differently. I think that an object has to be focused
for being clicked/when it's clicked, therefor the previous focus holder
must already have lost the focus, since only one object (on the same
hierarchy level) should be focused at the same time.

See the attached example code, that exposes the behavior.

-- 
Leif
#include <stdio.h>
#include <elementary-1/Elementary.h>

static void __mouse_clicked_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void __focus_out_cb(void *data, Evas_Object *obj, void *event_info);

EAPI_MAIN int
elm_main(int argc, char **argv)
{
   unsigned int i;
   Evas_Object *win, *bg, *bx;

   win = elm_win_add(NULL, "OddSequence", ELM_WIN_BASIC);
   elm_win_title_set(win, "Odd Callback Sequence");
   elm_win_autodel_set(win, EINA_TRUE);
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);

   bg = elm_bg_add(win);
   elm_win_resize_object_add(win, bg);
   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bg);

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, bx);
   elm_box_horizontal_set(bx, EINA_TRUE);
   evas_object_show(bx);

   for (i = 1; i <= 2; i++)
   {
       char buf[16];
       Evas_Object *bt = elm_button_add(win);
       snprintf(buf, (sizeof(buf) - 1), "Button %i", i);
       elm_object_text_set(bt, buf);

       evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
       evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);

       evas_object_event_callback_add(bt, EVAS_CALLBACK_MOUSE_UP, __mouse_clicked_cb, NULL);
       evas_object_smart_callback_add(bt, "unfocused", __focus_out_cb, NULL);

       elm_box_pack_end(bx, bt);
       evas_object_show(bt);
   }

   evas_object_resize(win, 320, 240);
   evas_object_show(win);

   elm_run();
   elm_shutdown();

   return 0;
}
ELM_MAIN()

    static void
__focus_out_cb(void *data, Evas_Object *vci, void *event_info)
{
    printf("focus out called\n");
}

    static void
__mouse_clicked_cb(void *data, Evas *evas, Evas_Object *vent_ctrl_obj, void *event_info)
{
    printf("mouse clicked called!\n");
}


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to