genlist: select the focused item on enter key input
authorJaeun Choi <jaeun12.choi@samsung.com>
Thu, 12 Feb 2015 08:31:00 +0000 (17:31 +0900)
committerJaeun Choi <jaeun12.choi@samsung.com>
Wed, 11 Mar 2015 08:14:54 +0000 (17:14 +0900)
there was no way to select an item with key input on ELM_ITEM_SELECT_ON_FOCUS_DISABLE mode.
this patch enables select and multi select with enter/space key input.

@fix

config/default/base.src.in
config/mobile/base.src.in
config/standard/base.src.in
src/lib/elm_genlist.c

index 35f9984..78b3873 100644 (file)
@@ -1243,18 +1243,72 @@ group "Elm_Config" struct {
               value "key" string: "Return";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "KP_Enter";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "space";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
index 4e4afd4..127c8a9 100644 (file)
@@ -1247,18 +1247,72 @@ group "Elm_Config" struct {
               value "key" string: "Return";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "KP_Enter";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "space";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
index e55f879..b7f9a4b 100644 (file)
@@ -1244,18 +1244,72 @@ group "Elm_Config" struct {
               value "key" string: "Return";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "KP_Enter";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
               value "key" string: "space";
               value "action" string: "select";
               value "params" string: "";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 0;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "select";
+              value "params" string: "multi";
+              group "modifiers" list {
+                 group "Elm_Config_Binding_Modifier" struct {
+                    value "mod" string: "Control";
+                    value "flag" uchar: 1;
+                 }
+              }
            }
            group "Elm_Config_Binding_Key" struct {
               value "context" int: 0;
index f659bd7..0678227 100644 (file)
@@ -141,6 +141,8 @@ static const char SIGNAL_GROUP_MIDDLE[] = "elm,state,group,middle";
 
 static void _item_unrealize(Elm_Gen_Item *it);
 static Eina_Bool _item_select(Elm_Gen_Item *it);
+static void _item_unselect(Elm_Gen_Item *it);
+static void _item_highlight(Elm_Gen_Item *it);
 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
 static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
 static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
@@ -2866,7 +2868,7 @@ _key_action_move(Evas_Object *obj, const char *params)
 }
 
 static Eina_Bool
-_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
+_key_action_select(Evas_Object *obj, const char *params)
 {
    Elm_Object_Item *eo_it = NULL;
 
@@ -2874,9 +2876,53 @@ _key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
    if (!eo_it) return EINA_TRUE;
    elm_genlist_item_expanded_set(eo_it, !elm_genlist_item_expanded_get(eo_it));
    ELM_GENLIST_ITEM_DATA_GET(eo_it, it);
+   ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
+
+   if (sd->multi &&
+       ((sd->multi_select_mode != ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL) ||
+        (!strcmp(params, "multi"))))
+     {
+        if (!it->selected)
+          {
+             _item_highlight(it);
+             if (_item_select(it)) goto deleted;
+          }
+        else
+         _item_unselect(it);
+     }
+   else
+     {
+        if (!it->selected)
+          {
+             while (sd->selected)
+               {
+                  Elm_Object_Item *eo_sel = sd->selected->data;
+                  Elm_Gen_Item *sel = eo_data_scope_get(eo_sel, ELM_GENLIST_ITEM_CLASS);
+                  _item_unselect(sel);
+               }
+          }
+        else
+          {
+             const Eina_List *l, *l_next;
+             Elm_Object_Item *eo_it2;
+
+             EINA_LIST_FOREACH_SAFE(sd->selected, l, l_next, eo_it2)
+               {
+                  ELM_GENLIST_ITEM_DATA_GET(eo_it2, it2);
+                  if (it2 != it)
+                    _item_unselect(it2);
+               }
+          }
+        _item_highlight(it);
+        if (_item_select(it)) goto deleted;
+     }
+
    evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, EO_OBJ(it));
 
    return EINA_TRUE;
+
+deleted:
+   return EINA_FALSE;
 }
 
 static Eina_Bool
@@ -7673,6 +7719,7 @@ _elm_genlist_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUS
           { "move,first", "move", "first", _key_action_move},
           { "move,last", "move", "last", _key_action_move},
           { "select", "select", NULL, _key_action_select},
+          { "select,multi", "select", "multi", _key_action_select},
           { "escape", "escape", NULL, _key_action_escape},
           { NULL, NULL, NULL, NULL }
    };