fileselector: apply key binding

Summary: This patch applies key binding to elm_fileselector.

Test Plan: elementary_test > fileselector > check key events

Reviewers: Hermet, raster

Differential Revision: https://phab.enlightenment.org/D728
This commit is contained in:
Jaeun Choi 2014-04-15 13:58:01 +09:00 committed by ChunEon Park
parent fbcadfd87a
commit 530fcf2d8c
4 changed files with 93 additions and 6 deletions

View File

@ -248,6 +248,29 @@ group "Elm_Config" struct {
}
}
group "bindings" list {
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elc_Fileselector";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Return";
value "action" string: "select";
value "params" string: "";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Enter";
value "action" string: "select";
value "params" string: "";
}
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: "Elm_Button";
group "key_bindings" list {

View File

@ -252,6 +252,29 @@ group "Elm_Config" struct {
}
}
group "bindings" list {
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elc_Fileselector";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Return";
value "action" string: "select";
value "params" string: "";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Enter";
value "action" string: "select";
value "params" string: "";
}
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: "Elm_Button";
group "key_bindings" list {

View File

@ -249,6 +249,29 @@ group "Elm_Config" struct {
}
}
group "bindings" list {
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elc_Fileselector";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Return";
value "action" string: "select";
value "params" string: "";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Enter";
value "action" string: "select";
value "params" string: "";
}
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: "Elm_Button";
group "key_bindings" list {

View File

@ -42,6 +42,15 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
};
#undef ELM_PRIV_FILESELECTOR_SIGNALS
static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
static const Elm_Action key_actions[] = {
{"select", _key_action_select},
{"escape", _key_action_escape},
{NULL, NULL}
};
static void _ok(void *data, Evas_Object *obj, void *event_info);
static void _canc(void *data, Evas_Object *obj, void *event_info);
@ -137,6 +146,20 @@ _elc_fileselector_elm_widget_theme_apply(Eo *obj, Elc_Fileselector_Data *sd)
return EINA_TRUE;
}
static Eina_Bool
_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
{
_ok(obj, NULL, NULL);
return EINA_TRUE;
}
static Eina_Bool
_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
{
_canc(obj, NULL, NULL);
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_elc_fileselector_elm_widget_event(Eo *obj, Elc_Fileselector_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
{
@ -147,12 +170,7 @@ _elc_fileselector_elm_widget_event(Eo *obj, Elc_Fileselector_Data *sd EINA_UNUSE
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, "Return")) ||
(!strcmp(ev->key, "KP_Enter")))
_ok(obj, NULL, NULL);
else if (!strcmp(ev->key, "Escape"))
_canc(obj, NULL, NULL);
else
if (!_elm_config_key_binding_call(obj, ev, key_actions))
return EINA_FALSE;
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;