elm:list: Avoiding two items be focused at same action
authorFlavio Ceolin <flavio.ceolin@intel.com>
Mon, 17 Mar 2014 19:55:08 +0000 (16:55 -0300)
committerFlavio Ceolin <flavio.ceolin@intel.com>
Mon, 17 Mar 2014 22:11:59 +0000 (19:11 -0300)
On a list that have not received focus yet a mouse down gives the focus
for the list (that gives the focus for the first item) and the mouse
up the item is selected and receive the focus.

The problem:  if the list is scrolled the focus given for the
first item makes the list scroll to the top and not for the item
selected by the user.

src/lib/elm_list.c
src/lib/elm_widget_list.h

index 9d703d4..478125a 100644 (file)
@@ -1062,12 +1062,15 @@ _elm_list_smart_on_focus(Eo *obj, void *_pd, va_list *list)
 
    if (elm_widget_focus_get(obj))
      {
-        if (sd->last_focused_item)
-          _elm_list_item_focused((Elm_List_Item *)sd->last_focused_item);
-        else if (sd->last_selected_item)
-          _elm_list_item_focused((Elm_List_Item *)sd->last_selected_item);
-        else
-          _elm_list_item_focused((Elm_List_Item *)eina_list_data_get(sd->items));
+        if (!sd->highlighted_item)
+          {
+             if (sd->last_focused_item)
+                _elm_list_item_focused((Elm_List_Item *)sd->last_focused_item);
+             else if (sd->last_selected_item)
+                _elm_list_item_focused((Elm_List_Item *)sd->last_selected_item);
+             else
+                _elm_list_item_focused((Elm_List_Item *)eina_list_data_get(sd->items));
+          }
         _elm_widget_focus_highlight_start(obj);
      }
    else
@@ -1144,7 +1147,7 @@ _item_highlight(Elm_List_Item *it)
    if ((select_raise) && (!strcmp(select_raise, "on")))
      evas_object_raise(VIEW(it));
    it->highlighted = EINA_TRUE;
-
+   sd->highlighted_item = it;
    _elm_list_unwalk(obj, sd);
    evas_object_unref(obj);
 }
@@ -1211,6 +1214,7 @@ _item_unhighlight(Elm_List_Item *it)
      }
    it->highlighted = EINA_FALSE;
 
+   sd->highlighted_item = NULL;
    _elm_list_unwalk(obj, sd);
    evas_object_unref(obj);
 }
index 06562da..fcca175 100644 (file)
@@ -53,6 +53,7 @@ struct _Elm_List_Smart_Data
    Eina_Bool                             multi : 1;
    Eina_Bool                             swipe : 1;
    Eina_Bool                             delete_me : 1;
+   Elm_Object_Item                      *highlighted_item;
 };
 
 typedef struct _Elm_List_Item Elm_List_Item;