From 71149158e217a10a95a3028a8276f9b579c596c5 Mon Sep 17 00:00:00 2001 From: Jaeun Choi Date: Tue, 15 Apr 2014 14:47:19 +0900 Subject: [PATCH] popup: apply key binding Summary: This patch applies key binding to elc_popup. Test Plan: None Reviewers: Hermet, raster Reviewed By: Hermet Differential Revision: https://phab.enlightenment.org/D731 --- legacy/elementary/config/default/base.src | 77 ++++++++++++++++++++++ legacy/elementary/config/mobile/base.src | 77 ++++++++++++++++++++++ legacy/elementary/config/standard/base.src | 77 ++++++++++++++++++++++ legacy/elementary/src/lib/elc_popup.c | 68 +++++++++---------- 4 files changed, 263 insertions(+), 36 deletions(-) diff --git a/legacy/elementary/config/default/base.src b/legacy/elementary/config/default/base.src index dad2675d86..f3729f457d 100644 --- a/legacy/elementary/config/default/base.src +++ b/legacy/elementary/config/default/base.src @@ -324,6 +324,83 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Popup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "previous"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 1; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "next"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 0; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "move"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "move"; + value "params" string: "down"; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Button"; group "key_bindings" list { diff --git a/legacy/elementary/config/mobile/base.src b/legacy/elementary/config/mobile/base.src index 76226d6c38..b3c7c624fb 100644 --- a/legacy/elementary/config/mobile/base.src +++ b/legacy/elementary/config/mobile/base.src @@ -328,6 +328,83 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Popup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "previous"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 1; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "next"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 0; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "move"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "move"; + value "params" string: "down"; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Button"; group "key_bindings" list { diff --git a/legacy/elementary/config/standard/base.src b/legacy/elementary/config/standard/base.src index 7c0a1a095f..0c7d55e2ec 100644 --- a/legacy/elementary/config/standard/base.src +++ b/legacy/elementary/config/standard/base.src @@ -325,6 +325,83 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Popup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "previous"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 1; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tap"; + value "action" string: "move"; + value "params" string: "next"; + group "modifiers" list { + group "Elm_Config_Binding_Modifier" struct { + value "mod" string: "Shift"; + value "flag" uchar: 0; + } + } + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "move"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "move"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "move"; + value "params" string: "down"; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Button"; group "key_bindings" list { diff --git a/legacy/elementary/src/lib/elc_popup.c b/legacy/elementary/src/lib/elc_popup.c index bbe861c105..9e142cbb0e 100644 --- a/legacy/elementary/src/lib/elc_popup.c +++ b/legacy/elementary/src/lib/elc_popup.c @@ -36,6 +36,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {NULL, NULL} }; +static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); + +static const Elm_Action key_actions[] = { + {"move", _key_action_move}, + {NULL, NULL} +}; + static void _on_content_del(void *data, Evas *e, Evas_Object *obj, void *event_info); EOLIAN static Eina_Bool @@ -1431,6 +1438,29 @@ _elc_popup_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elc_Popup_Data *sd, c return EINA_TRUE; } +static Eina_Bool +_key_action_move(Evas_Object *obj, const char *params) +{ + const char *dir = params; + + if (!strcmp(dir, "previous")) + elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS); + else if (!strcmp(dir, "next")) + elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT); + else if (!strcmp(dir, "left")) + elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT); + else if (!strcmp(dir, "right")) + elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT); + else if (!strcmp(dir, "up")) + elm_widget_focus_cycle(obj, ELM_FOCUS_UP); + else if (!strcmp(dir, "down")) + elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN); + else return EINA_FALSE; + + return EINA_TRUE; + +} + EOLIAN static Eina_Bool _elc_popup_elm_widget_event(Eo *obj, Elc_Popup_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) { @@ -1441,43 +1471,9 @@ _elc_popup_elm_widget_event(Eo *obj, Elc_Popup_Data *_pd EINA_UNUSED, Evas_Objec if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - if (!strcmp(ev->key, "Tab")) - { - if (evas_key_modifier_is_set(ev->modifiers, "Shift")) - elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS); - else - elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT); + if (!_elm_config_key_binding_call(obj, ev, key_actions)) + return EINA_FALSE; - goto success; - } - else if ((!strcmp(ev->key, "Left")) || - ((!strcmp(ev->key, "KP_Left")) && (!ev->string))) - { - elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT); - goto success; - } - else if ((!strcmp(ev->key, "Right")) || - ((!strcmp(ev->key, "KP_Right")) && (!ev->string))) - { - elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT); - goto success; - } - else if ((!strcmp(ev->key, "Up")) || - ((!strcmp(ev->key, "KP_Up")) && (!ev->string))) - { - elm_widget_focus_cycle(obj, ELM_FOCUS_UP); - goto success; - } - else if ((!strcmp(ev->key, "Down")) || - ((!strcmp(ev->key, "KP_Down")) && (!ev->string))) - { - elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN); - goto success; - } - - return EINA_FALSE; - -success: ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; }