hermet pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=b22746e828f56d2a7d9568888fe4e3266e9cda57
commit b22746e828f56d2a7d9568888fe4e3266e9cda57 Author: Jaeun Choi <jaeun12.c...@samsung.com> Date: Thu Apr 17 15:41:50 2014 +0900 ctxpopup: apply key binding Summary: This patch applies key binding to elc_ctxpopup. Test Plan: None Reviewers: Hermet, raster Differential Revision: https://phab.enlightenment.org/D754 --- config/default/base.src | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ config/mobile/base.src | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ config/standard/base.src | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elc_ctxpopup.c | 73 +++++++++++++++++++++++++----------------- 4 files changed, 292 insertions(+), 30 deletions(-) diff --git a/config/default/base.src b/config/default/base.src index 64e3026..61e0438 100644 --- a/config/default/base.src +++ b/config/default/base.src @@ -249,6 +249,89 @@ group "Elm_Config" struct { } group "bindings" list { group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Ctxpopup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tab"; + 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: "Tab"; + 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_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Escape"; + value "action" string: "escape"; + value "params" string: ""; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elc_Fileselector"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/config/mobile/base.src b/config/mobile/base.src index 8f33557..a40d376 100644 --- a/config/mobile/base.src +++ b/config/mobile/base.src @@ -253,6 +253,89 @@ group "Elm_Config" struct { } group "bindings" list { group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Ctxpopup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tab"; + 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: "Tab"; + 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_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Escape"; + value "action" string: "escape"; + value "params" string: ""; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elc_Fileselector"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/config/standard/base.src b/config/standard/base.src index e4b903b..4b58b53 100644 --- a/config/standard/base.src +++ b/config/standard/base.src @@ -250,6 +250,89 @@ group "Elm_Config" struct { } group "bindings" list { group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elc_Ctxpopup"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Tab"; + 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: "Tab"; + 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_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Escape"; + value "action" string: "escape"; + value "params" string: ""; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elc_Fileselector"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c index 5dffe28..a4ea92b 100644 --- a/src/lib/elc_ctxpopup.c +++ b/src/lib/elc_ctxpopup.c @@ -29,6 +29,15 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { }; #undef ELM_PRIV_CTXPOPUP_SIGNALS +static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); +static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params); + +static const Elm_Action key_actions[] = { + {"move", _key_action_move}, + {"escape", _key_action_escape}, + {NULL, NULL} +}; + EOLIAN static Eina_Bool _elc_ctxpopup_elm_widget_translate(Eo *obj, Elc_Ctxpopup_Data *sd) { @@ -94,8 +103,40 @@ _elc_ctxpopup_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elc_Ctxpopup_Data return int_ret; } +static Eina_Bool +_key_action_move(Evas_Object *obj, const char *params) +{ + ELM_CTXPOPUP_DATA_GET(obj, sd); + const char *dir = params; + + if (!sd->box) return EINA_FALSE; + + if (!strcmp(dir, "previous")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_PREVIOUS); + else if (!strcmp(dir, "next")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_NEXT); + else if (!strcmp(dir, "left")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_LEFT); + else if (!strcmp(dir, "right")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_RIGHT); + else if (!strcmp(dir, "up")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_UP); + else if (!strcmp(dir, "down")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_DOWN); + else return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED) +{ + evas_object_hide(obj); + return EINA_TRUE; +} + EOLIAN static Eina_Bool -_elc_ctxpopup_elm_widget_event(Eo *obj, Elc_Ctxpopup_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info) +_elc_ctxpopup_elm_widget_event(Eo *obj, Elc_Ctxpopup_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) { Evas_Event_Key_Down *ev = event_info; (void)src; @@ -103,37 +144,9 @@ _elc_ctxpopup_elm_widget_event(Eo *obj, Elc_Ctxpopup_Data *sd, Evas_Object *src, if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - if (sd->box) - { - if (!strcmp(ev->key, "Tab")) - { - if (evas_key_modifier_is_set(ev->modifiers, "Shift")) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_PREVIOUS); - else - elm_widget_focus_cycle(sd->box, ELM_FOCUS_NEXT); - } - else if ((!strcmp(ev->key, "Left")) || - ((!strcmp(ev->key, "KP_Left")) && (!ev->string))) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_LEFT); - else if ((!strcmp(ev->key, "Right")) || - ((!strcmp(ev->key, "KP_Right")) && (!ev->string))) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_RIGHT); - else if ((!strcmp(ev->key, "Up")) || - ((!strcmp(ev->key, "KP_Up")) && (!ev->string))) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_UP); - else if ((!strcmp(ev->key, "Down")) || - ((!strcmp(ev->key, "KP_Down")) && (!ev->string))) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_DOWN); - - goto success; - } - - if (!strcmp(ev->key, "Escape")) - evas_object_hide(obj); - else + if (!_elm_config_key_binding_call(obj, ev, key_actions)) return EINA_FALSE; -success: ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; } --