As other widgets, efl.ui.textbox will use keyboard bindings instead of listen to keyboard events
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11236
group "Elm_Config" struct {
- value "config_version" int: 131094;
+ value "config_version" int: 131095;
value "entry_select_allow" uchar: 1;
value "engine" string: "";
value "vsync" uchar: 0;
value "action" string: "move";
value "params" string: "next";
}
- }
- }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Efl.Ui.Textbox";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "c";
+ value "action" string: "copy";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "x";
+ value "action" string: "cut";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "v";
+ value "action" string: "paste";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "menu";
+ value "action" string: "menu";
+ value "params" string: "";
+ }
+ }
+ }
}
}
group "Elm_Config" struct {
- value "config_version" int: 131094;
+ value "config_version" int: 131095;
value "entry_select_allow" uchar: 1;
value "engine" string: "";
value "vsync" uchar: 0;
value "action" string: "move";
value "params" string: "next";
}
- }
- }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Efl.Ui.Textbox";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "c";
+ value "action" string: "copy";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "x";
+ value "action" string: "cut";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "v";
+ value "action" string: "paste";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "menu";
+ value "action" string: "menu";
+ value "params" string: "";
+ }
+ }
+ }
}
}
group "Elm_Config" struct {
- value "config_version" int: 131094;
+ value "config_version" int: 131095;
value "entry_select_allow" uchar: 1;
value "engine" string: "";
value "vsync" uchar: 0;
value "action" string: "move";
value "params" string: "next";
}
- }
- }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Efl.Ui.Textbox";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "c";
+ value "action" string: "copy";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "x";
+ value "action" string: "cut";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "v";
+ value "action" string: "paste";
+ value "params" string: "";
+ group "modifiers" list {
+ group "Elm_Config_Binding_Modifier" struct {
+ value "mod" string: "Control";
+ value "flag" uchar: 1;
+ }
+ }
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "menu";
+ value "action" string: "menu";
+ value "params" string: "";
+ }
+ }
+ }
}
}
static void _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd);
static void _efl_ui_textbox_selection_paste_type(Eo *obj, Efl_Ui_Selection_Type type);
+static Eina_Bool _key_action_copy(Evas_Object *obj, const char *params);
+static Eina_Bool _key_action_paste(Evas_Object *obj, const char *params);
+static Eina_Bool _key_action_cut(Evas_Object *obj, const char *params);
+static Eina_Bool _key_action_menu(Evas_Object *obj, const char *params);
+
+static const Elm_Action key_actions[] = {
+ {"copy", _key_action_copy},
+ {"paste", _key_action_paste},
+ {"cut", _key_action_cut},
+ {"menu", _key_action_menu},
+ {NULL, NULL}
+};
+
static void
_efl_ui_textbox_guide_update(Evas_Object *obj,
Eina_Bool has_text)
sd->long_pressed = EINA_TRUE;
}
-static void
-_key_down_cb(void *data, const Efl_Event *event)
+
+static Eina_Bool
+_key_action_copy(Evas_Object *obj, const char *params EINA_UNUSED)
{
- Efl_Input_Key_Data *ev = efl_data_scope_get(event->info, EFL_INPUT_KEY_CLASS);
- Eina_Bool on_hold = EINA_FALSE;
+ efl_ui_textbox_selection_copy(obj);
+ return EINA_TRUE;
+}
- /* First check if context menu disabled is false or not, and
- * then check for key id */
- if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu"))
- {
- _menu_call(data);
- on_hold = EINA_TRUE;
- }
- else
- {
-#if defined(__APPLE__) && defined(__MACH__)
- Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Super");
-#else
- Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Control");
-#endif
+static Eina_Bool
+_key_action_cut(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+ efl_ui_textbox_selection_cut(obj);
+ return EINA_TRUE;
+}
- /* Ctrl operations */
- if (control)
- {
- if (!strncmp(ev->key, "c", 1))
- {
- efl_ui_textbox_selection_copy(data);
- on_hold = EINA_TRUE;
- }
- else if (!strncmp(ev->key, "x", 1))
- {
- efl_ui_textbox_selection_cut(data);
- on_hold = EINA_TRUE;
- }
- else if (!strncmp(ev->key, "v", 1))
- {
- efl_ui_textbox_selection_paste(data);
- on_hold = EINA_TRUE;
- }
- }
- }
+static Eina_Bool
+_key_action_paste(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+ efl_ui_textbox_selection_paste(obj);
+ return EINA_TRUE;
+}
- if (on_hold) ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+static Eina_Bool
+_key_action_menu(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+ Eina_Bool b_ret = EINA_FALSE;
+ if (!_elm_config->context_menu_disabled)
+ {
+ _menu_call(obj);
+ b_ret = EINA_TRUE;
+ }
+ return b_ret;
}
static void
_efl_ui_textbox_move_cb, obj);
efl_event_callback_add
- (sd->entry_edje, EFL_EVENT_KEY_DOWN, _key_down_cb, obj);
- efl_event_callback_add
(sd->entry_edje, EFL_EVENT_POINTER_DOWN, _mouse_down_cb, obj);
efl_event_callback_add
(sd->entry_edje, EFL_EVENT_POINTER_UP, _mouse_up_cb, obj);
return EINA_FALSE;
}
+/* Standard widget overrides */
+
+ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_textbox, Efl_Ui_Textbox_Data)
+
ELM_PART_OVERRIDE_PARTIAL(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_textbox_part)
ELM_PART_OVERRIDE_TEXT_SET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data)
ELM_PART_OVERRIDE_TEXT_GET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data)
Efl.Canvas.Group.group_calculate;
Efl.Ui.Widget.on_access_activate;
Efl.Ui.Widget.theme_apply;
+ Efl.Ui.Widget.widget_input_event_handler;
Efl.Ui.Focus.Object.on_focus_update;
Efl.Ui.Widget.interest_region { get; }
Efl.Ui.Widget.disabled {set;}
tcfg = _config_system_load();
IFCFGEND
+ IFCFG(0x0017)
+ _elm_key_bindings_copy_missing_bindings_of_widget(_elm_config, tcfg, "Efl.Ui.Textbox");
+ /* after this function call, the tcfg is partly invalidated, reload! */
+ _config_free(tcfg);
+ tcfg = _config_system_load();
+ IFCFGEND
/**
* Fix user config for current ELM_CONFIG_EPOCH here.
**/
* the users config doesn't need to be wiped - simply new values need
* to be put in
*/
-# define ELM_CONFIG_FILE_GENERATION 0x0016
+# define ELM_CONFIG_FILE_GENERATION 0x0017
# define ELM_CONFIG_VERSION_EPOCH_OFFSET 16
# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
ELM_CONFIG_FILE_GENERATION)