diff --git a/data/elementary/config/default/base.src.in b/data/elementary/config/default/base.src.in index 2b8828967b..d45a704b5a 100644 --- a/data/elementary/config/default/base.src.in +++ b/data/elementary/config/default/base.src.in @@ -1,5 +1,5 @@ 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; @@ -3275,7 +3275,54 @@ group "Elm_Config" struct { 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: ""; + } + } + } } } diff --git a/data/elementary/config/mobile/base.src.in b/data/elementary/config/mobile/base.src.in index 9077d3bf8d..0883545e21 100644 --- a/data/elementary/config/mobile/base.src.in +++ b/data/elementary/config/mobile/base.src.in @@ -1,5 +1,5 @@ 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; @@ -3261,7 +3261,54 @@ group "Elm_Config" struct { 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: ""; + } + } + } } } diff --git a/data/elementary/config/standard/base.src.in b/data/elementary/config/standard/base.src.in index a64711b376..391eb5baf3 100644 --- a/data/elementary/config/standard/base.src.in +++ b/data/elementary/config/standard/base.src.in @@ -1,5 +1,5 @@ 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; @@ -3258,7 +3258,54 @@ group "Elm_Config" struct { 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: ""; + } + } + } } } diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c index 705ac1bef4..024181cc21 100644 --- a/src/lib/elementary/efl_ui_textbox.c +++ b/src/lib/elementary/efl_ui_textbox.c @@ -210,6 +210,19 @@ static Eina_Position2D _decoration_calc_offset(Efl_Ui_Textbox_Data *sd); 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) @@ -1050,49 +1063,38 @@ _long_press_cb(void *data, const Efl_Event *ev EINA_UNUSED) 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")) +static Eina_Bool +_key_action_cut(Evas_Object *obj, const char *params EINA_UNUSED) +{ + efl_ui_textbox_selection_cut(obj); + return 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; +} + +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(data); - on_hold = EINA_TRUE; + _menu_call(obj); + b_ret = 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 - - /* 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; - } - } - } - - if (on_hold) ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + return b_ret; } static void @@ -1698,8 +1700,6 @@ _efl_ui_textbox_efl_object_finalize(Eo *obj, efl_event_callback_add(sd->entry_edje, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, _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 @@ -3330,6 +3330,10 @@ _part_is_efl_ui_textbox_part(const Eo *obj EINA_UNUSED, const char *part) 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) diff --git a/src/lib/elementary/efl_ui_textbox.eo b/src/lib/elementary/efl_ui_textbox.eo index dc3c428f1b..2b7ccf9472 100644 --- a/src/lib/elementary/efl_ui_textbox.eo +++ b/src/lib/elementary/efl_ui_textbox.eo @@ -92,6 +92,7 @@ class @beta Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements Efl.Input.Click 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;} diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index 63eda20a3f..f6ff33cf0a 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -2474,6 +2474,12 @@ _config_update(void) 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. **/ diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 87e6bdb0bf..89878716f3 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -271,7 +271,7 @@ struct _Efl_Ui_Theme_Data * 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)