summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-02-02 14:07:45 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-04 09:14:04 +0100
commita92f8c210bb6d224300a069fce5d7f65f0a8e059 (patch)
tree931ebb3a854a0ab563c9908afb351155a3f35280 /src/lib
parent1587d7fa1bbac672139b870a252827b4f9ddc413 (diff)
efl.ui.textbox: add and use keyboard bindings
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_textbox.c86
-rw-r--r--src/lib/elementary/efl_ui_textbox.eo1
-rw-r--r--src/lib/elementary/elm_config.c6
-rw-r--r--src/lib/elementary/elm_priv.h2
4 files changed, 53 insertions, 42 deletions
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);
210static void _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd); 210static void _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd);
211static void _efl_ui_textbox_selection_paste_type(Eo *obj, Efl_Ui_Selection_Type type); 211static void _efl_ui_textbox_selection_paste_type(Eo *obj, Efl_Ui_Selection_Type type);
212 212
213static Eina_Bool _key_action_copy(Evas_Object *obj, const char *params);
214static Eina_Bool _key_action_paste(Evas_Object *obj, const char *params);
215static Eina_Bool _key_action_cut(Evas_Object *obj, const char *params);
216static Eina_Bool _key_action_menu(Evas_Object *obj, const char *params);
217
218static const Elm_Action key_actions[] = {
219 {"copy", _key_action_copy},
220 {"paste", _key_action_paste},
221 {"cut", _key_action_cut},
222 {"menu", _key_action_menu},
223 {NULL, NULL}
224};
225
213static void 226static void
214_efl_ui_textbox_guide_update(Evas_Object *obj, 227_efl_ui_textbox_guide_update(Evas_Object *obj,
215 Eina_Bool has_text) 228 Eina_Bool has_text)
@@ -1050,49 +1063,38 @@ _long_press_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1050 sd->long_pressed = EINA_TRUE; 1063 sd->long_pressed = EINA_TRUE;
1051} 1064}
1052 1065
1053static void 1066
1054_key_down_cb(void *data, const Efl_Event *event) 1067static Eina_Bool
1068_key_action_copy(Evas_Object *obj, const char *params EINA_UNUSED)
1055{ 1069{
1056 Efl_Input_Key_Data *ev = efl_data_scope_get(event->info, EFL_INPUT_KEY_CLASS); 1070 efl_ui_textbox_selection_copy(obj);
1057 Eina_Bool on_hold = EINA_FALSE; 1071 return EINA_TRUE;
1072}
1058 1073
1059 /* First check if context menu disabled is false or not, and 1074static Eina_Bool
1060 * then check for key id */ 1075_key_action_cut(Evas_Object *obj, const char *params EINA_UNUSED)
1061 if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu")) 1076{
1062 { 1077 efl_ui_textbox_selection_cut(obj);
1063 _menu_call(data); 1078 return EINA_TRUE;
1064 on_hold = EINA_TRUE; 1079}
1065 }
1066 else
1067 {
1068#if defined(__APPLE__) && defined(__MACH__)
1069 Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Super");
1070#else
1071 Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Control");
1072#endif
1073 1080
1074 /* Ctrl operations */ 1081static Eina_Bool
1075 if (control) 1082_key_action_paste(Evas_Object *obj, const char *params EINA_UNUSED)
1076 { 1083{
1077 if (!strncmp(ev->key, "c", 1)) 1084 efl_ui_textbox_selection_paste(obj);
1078 { 1085 return EINA_TRUE;
1079 efl_ui_textbox_selection_copy(data); 1086}
1080 on_hold = EINA_TRUE;
1081 }
1082 else if (!strncmp(ev->key, "x", 1))
1083 {
1084 efl_ui_textbox_selection_cut(data);
1085 on_hold = EINA_TRUE;
1086 }
1087 else if (!strncmp(ev->key, "v", 1))
1088 {
1089 efl_ui_textbox_selection_paste(data);
1090 on_hold = EINA_TRUE;
1091 }
1092 }
1093 }
1094 1087
1095 if (on_hold) ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1088static Eina_Bool
1089_key_action_menu(Evas_Object *obj, const char *params EINA_UNUSED)
1090{
1091 Eina_Bool b_ret = EINA_FALSE;
1092 if (!_elm_config->context_menu_disabled)
1093 {
1094 _menu_call(obj);
1095 b_ret = EINA_TRUE;
1096 }
1097 return b_ret;
1096} 1098}
1097 1099
1098static void 1100static void
@@ -1699,8 +1701,6 @@ _efl_ui_textbox_efl_object_finalize(Eo *obj,
1699 _efl_ui_textbox_move_cb, obj); 1701 _efl_ui_textbox_move_cb, obj);
1700 1702
1701 efl_event_callback_add 1703 efl_event_callback_add
1702 (sd->entry_edje, EFL_EVENT_KEY_DOWN, _key_down_cb, obj);
1703 efl_event_callback_add
1704 (sd->entry_edje, EFL_EVENT_POINTER_DOWN, _mouse_down_cb, obj); 1704 (sd->entry_edje, EFL_EVENT_POINTER_DOWN, _mouse_down_cb, obj);
1705 efl_event_callback_add 1705 efl_event_callback_add
1706 (sd->entry_edje, EFL_EVENT_POINTER_UP, _mouse_up_cb, obj); 1706 (sd->entry_edje, EFL_EVENT_POINTER_UP, _mouse_up_cb, obj);
@@ -3330,6 +3330,10 @@ _part_is_efl_ui_textbox_part(const Eo *obj EINA_UNUSED, const char *part)
3330 return EINA_FALSE; 3330 return EINA_FALSE;
3331} 3331}
3332 3332
3333/* Standard widget overrides */
3334
3335ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_textbox, Efl_Ui_Textbox_Data)
3336
3333ELM_PART_OVERRIDE_PARTIAL(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_textbox_part) 3337ELM_PART_OVERRIDE_PARTIAL(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_textbox_part)
3334ELM_PART_OVERRIDE_TEXT_SET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data) 3338ELM_PART_OVERRIDE_TEXT_SET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data)
3335ELM_PART_OVERRIDE_TEXT_GET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data) 3339ELM_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
92 Efl.Canvas.Group.group_calculate; 92 Efl.Canvas.Group.group_calculate;
93 Efl.Ui.Widget.on_access_activate; 93 Efl.Ui.Widget.on_access_activate;
94 Efl.Ui.Widget.theme_apply; 94 Efl.Ui.Widget.theme_apply;
95 Efl.Ui.Widget.widget_input_event_handler;
95 Efl.Ui.Focus.Object.on_focus_update; 96 Efl.Ui.Focus.Object.on_focus_update;
96 Efl.Ui.Widget.interest_region { get; } 97 Efl.Ui.Widget.interest_region { get; }
97 Efl.Ui.Widget.disabled {set;} 98 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)
2474 tcfg = _config_system_load(); 2474 tcfg = _config_system_load();
2475 IFCFGEND 2475 IFCFGEND
2476 2476
2477 IFCFG(0x0017)
2478 _elm_key_bindings_copy_missing_bindings_of_widget(_elm_config, tcfg, "Efl.Ui.Textbox");
2479 /* after this function call, the tcfg is partly invalidated, reload! */
2480 _config_free(tcfg);
2481 tcfg = _config_system_load();
2482 IFCFGEND
2477 /** 2483 /**
2478 * Fix user config for current ELM_CONFIG_EPOCH here. 2484 * Fix user config for current ELM_CONFIG_EPOCH here.
2479 **/ 2485 **/
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
271 * the users config doesn't need to be wiped - simply new values need 271 * the users config doesn't need to be wiped - simply new values need
272 * to be put in 272 * to be put in
273 */ 273 */
274# define ELM_CONFIG_FILE_GENERATION 0x0016 274# define ELM_CONFIG_FILE_GENERATION 0x0017
275# define ELM_CONFIG_VERSION_EPOCH_OFFSET 16 275# define ELM_CONFIG_VERSION_EPOCH_OFFSET 16
276# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \ 276# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
277 ELM_CONFIG_FILE_GENERATION) 277 ELM_CONFIG_FILE_GENERATION)