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
This commit is contained in:
Jaeun Choi 2014-04-17 15:41:50 +09:00 committed by ChunEon Park
parent bde04f61e9
commit e88c793425
4 changed files with 292 additions and 30 deletions

View File

@ -248,6 +248,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 {

View File

@ -252,6 +252,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 {

View File

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

View File

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