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
}
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 {
group "Elm_Config_Binding_Key" 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 {
group "Elm_Config_Binding_Key" 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 {
group "Elm_Config_Binding_Key" struct {
};
#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);
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)
{
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;