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
This commit is contained in:
Jaeun Choi 2014-04-15 14:47:19 +09:00 committed by ChunEon Park
parent 16dd06bb8e
commit 71149158e2
4 changed files with 263 additions and 36 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}