Summary: This patch applied key bindiing to elc_hoversel.
Test Plan: None
Reviewers: Hermet, raster
Reviewed By: Hermet
Differential Revision: https://phab.enlightenment.org/D729
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elc_Hoversel";
+ group "key_bindings" list {
+ 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 {
group "Elm_Config_Binding_Key" struct {
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elc_Hoversel";
+ group "key_bindings" list {
+ 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 {
group "Elm_Config_Binding_Key" struct {
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elc_Hoversel";
+ group "key_bindings" list {
+ 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 {
group "Elm_Config_Binding_Key" struct {
{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}
+};
+
EOLIAN static Eina_Bool
_elc_hoversel_elm_widget_translate(Eo *obj EINA_UNUSED, Elc_Hoversel_Data *sd)
{
return NULL;
}
-EOLIAN static Eina_Bool
-_elc_hoversel_elm_widget_event(Eo *obj, Elc_Hoversel_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
+static Eina_Bool
+_key_action_move(Evas_Object *obj, const char *params)
{
- (void) src;
- Eina_Bool int_ret = EINA_FALSE;
- Evas_Event_Key_Down *ev = event_info;
+ ELM_HOVERSEL_DATA_GET(obj, sd);
+ const char *dir = params;
Elm_Hoversel_Item *litem, *fitem;
-
- eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_event(src, type, event_info));
- if (int_ret) return EINA_FALSE;
-
- if (!sd || !sd->hover) return EINA_FALSE;
- if (elm_widget_disabled_get(obj)) return EINA_FALSE;
- if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
- if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
-
litem = eina_list_last_data_get(sd->items);
fitem = eina_list_data_get(sd->items);
- if ((!strcmp(ev->key, "Down")) ||
- ((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
+ if (!strcmp(dir, "down"))
{
if (item_focused_get(sd) == litem)
{
elm_object_focus_set(VIEW(fitem), EINA_TRUE);
- goto success;
+ return EINA_TRUE;
}
elm_widget_focus_cycle(sd->hover, ELM_FOCUS_DOWN);
- goto success;
+ return EINA_TRUE;
}
- else if ((!strcmp(ev->key, "Up")) ||
- ((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
+ else if (!strcmp(dir, "up"))
{
if (item_focused_get(sd) == fitem)
{
elm_object_focus_set(VIEW(litem), EINA_TRUE);
- goto success;
+ return EINA_TRUE;
}
elm_widget_focus_cycle(sd->hover, ELM_FOCUS_UP);
- goto success;
+ return EINA_TRUE;
}
- else if ((!strcmp(ev->key, "Left")) ||
- ((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
+ else if (!strcmp(dir, "left"))
{
if (item_focused_get(sd) == fitem)
{
elm_object_focus_set(VIEW(litem), EINA_TRUE);
- goto success;
+ return EINA_TRUE;
}
elm_widget_focus_cycle(sd->hover, ELM_FOCUS_LEFT);
- goto success;
+ return EINA_TRUE;
}
- else if ((!strcmp(ev->key, "Right")) ||
- ((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
+ else if (!strcmp(dir, "right"))
{
if (item_focused_get(sd) == litem)
{
elm_object_focus_set(VIEW(fitem), EINA_TRUE);
- goto success;
+ return EINA_TRUE;
}
elm_widget_focus_cycle(sd->hover, ELM_FOCUS_RIGHT);
- goto success;
+ return EINA_TRUE;
}
+ else return EINA_FALSE;
+}
- return EINA_FALSE;
+EOLIAN static Eina_Bool
+_elc_hoversel_elm_widget_event(Eo *obj, Elc_Hoversel_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
+{
+ (void) src;
+ Eina_Bool int_ret = EINA_FALSE;
+ Evas_Event_Key_Down *ev = event_info;
- success:
- ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_event(src, type, event_info));
+ if (int_ret) return EINA_FALSE;
+ if (!sd || !sd->hover) return EINA_FALSE;
+ if (elm_widget_disabled_get(obj)) return EINA_FALSE;
+ if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
+
+ if (!_elm_config_key_binding_call(obj, ev, key_actions))
+ return EINA_FALSE;
+
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
return EINA_TRUE;
}