summaryrefslogtreecommitdiff
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
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
-rw-r--r--data/elementary/config/default/base.src.in53
-rw-r--r--data/elementary/config/mobile/base.src.in53
-rw-r--r--data/elementary/config/standard/base.src.in53
-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
7 files changed, 203 insertions, 51 deletions
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 @@
1group "Elm_Config" struct { 1group "Elm_Config" struct {
2 value "config_version" int: 131094; 2 value "config_version" int: 131095;
3 value "entry_select_allow" uchar: 1; 3 value "entry_select_allow" uchar: 1;
4 value "engine" string: ""; 4 value "engine" string: "";
5 value "vsync" uchar: 0; 5 value "vsync" uchar: 0;
@@ -3275,7 +3275,54 @@ group "Elm_Config" struct {
3275 value "action" string: "move"; 3275 value "action" string: "move";
3276 value "params" string: "next"; 3276 value "params" string: "next";
3277 } 3277 }
3278 } 3278 }
3279 } 3279 }
3280 group "Elm_Config_Bindings_Widget" struct {
3281 value "name" string: "Efl.Ui.Textbox";
3282 group "key_bindings" list {
3283 group "Elm_Config_Binding_Key" struct {
3284 value "context" int: 0;
3285 value "key" string: "c";
3286 value "action" string: "copy";
3287 value "params" string: "";
3288 group "modifiers" list {
3289 group "Elm_Config_Binding_Modifier" struct {
3290 value "mod" string: "Control";
3291 value "flag" uchar: 1;
3292 }
3293 }
3294 }
3295 group "Elm_Config_Binding_Key" struct {
3296 value "context" int: 0;
3297 value "key" string: "x";
3298 value "action" string: "cut";
3299 value "params" string: "";
3300 group "modifiers" list {
3301 group "Elm_Config_Binding_Modifier" struct {
3302 value "mod" string: "Control";
3303 value "flag" uchar: 1;
3304 }
3305 }
3306 }
3307 group "Elm_Config_Binding_Key" struct {
3308 value "context" int: 0;
3309 value "key" string: "v";
3310 value "action" string: "paste";
3311 value "params" string: "";
3312 group "modifiers" list {
3313 group "Elm_Config_Binding_Modifier" struct {
3314 value "mod" string: "Control";
3315 value "flag" uchar: 1;
3316 }
3317 }
3318 }
3319 group "Elm_Config_Binding_Key" struct {
3320 value "context" int: 0;
3321 value "key" string: "menu";
3322 value "action" string: "menu";
3323 value "params" string: "";
3324 }
3325 }
3326 }
3280 } 3327 }
3281} 3328}
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 @@
1group "Elm_Config" struct { 1group "Elm_Config" struct {
2 value "config_version" int: 131094; 2 value "config_version" int: 131095;
3 value "entry_select_allow" uchar: 1; 3 value "entry_select_allow" uchar: 1;
4 value "engine" string: ""; 4 value "engine" string: "";
5 value "vsync" uchar: 0; 5 value "vsync" uchar: 0;
@@ -3261,7 +3261,54 @@ group "Elm_Config" struct {
3261 value "action" string: "move"; 3261 value "action" string: "move";
3262 value "params" string: "next"; 3262 value "params" string: "next";
3263 } 3263 }
3264 } 3264 }
3265 } 3265 }
3266 group "Elm_Config_Bindings_Widget" struct {
3267 value "name" string: "Efl.Ui.Textbox";
3268 group "key_bindings" list {
3269 group "Elm_Config_Binding_Key" struct {
3270 value "context" int: 0;
3271 value "key" string: "c";
3272 value "action" string: "copy";
3273 value "params" string: "";
3274 group "modifiers" list {
3275 group "Elm_Config_Binding_Modifier" struct {
3276 value "mod" string: "Control";
3277 value "flag" uchar: 1;
3278 }
3279 }
3280 }
3281 group "Elm_Config_Binding_Key" struct {
3282 value "context" int: 0;
3283 value "key" string: "x";
3284 value "action" string: "cut";
3285 value "params" string: "";
3286 group "modifiers" list {
3287 group "Elm_Config_Binding_Modifier" struct {
3288 value "mod" string: "Control";
3289 value "flag" uchar: 1;
3290 }
3291 }
3292 }
3293 group "Elm_Config_Binding_Key" struct {
3294 value "context" int: 0;
3295 value "key" string: "v";
3296 value "action" string: "paste";
3297 value "params" string: "";
3298 group "modifiers" list {
3299 group "Elm_Config_Binding_Modifier" struct {
3300 value "mod" string: "Control";
3301 value "flag" uchar: 1;
3302 }
3303 }
3304 }
3305 group "Elm_Config_Binding_Key" struct {
3306 value "context" int: 0;
3307 value "key" string: "menu";
3308 value "action" string: "menu";
3309 value "params" string: "";
3310 }
3311 }
3312 }
3266 } 3313 }
3267} 3314}
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 @@
1group "Elm_Config" struct { 1group "Elm_Config" struct {
2 value "config_version" int: 131094; 2 value "config_version" int: 131095;
3 value "entry_select_allow" uchar: 1; 3 value "entry_select_allow" uchar: 1;
4 value "engine" string: ""; 4 value "engine" string: "";
5 value "vsync" uchar: 0; 5 value "vsync" uchar: 0;
@@ -3258,7 +3258,54 @@ group "Elm_Config" struct {
3258 value "action" string: "move"; 3258 value "action" string: "move";
3259 value "params" string: "next"; 3259 value "params" string: "next";
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 group "Elm_Config_Bindings_Widget" struct {
3264 value "name" string: "Efl.Ui.Textbox";
3265 group "key_bindings" list {
3266 group "Elm_Config_Binding_Key" struct {
3267 value "context" int: 0;
3268 value "key" string: "c";
3269 value "action" string: "copy";
3270 value "params" string: "";
3271 group "modifiers" list {
3272 group "Elm_Config_Binding_Modifier" struct {
3273 value "mod" string: "Control";
3274 value "flag" uchar: 1;
3275 }
3276 }
3277 }
3278 group "Elm_Config_Binding_Key" struct {
3279 value "context" int: 0;
3280 value "key" string: "x";
3281 value "action" string: "cut";
3282 value "params" string: "";
3283 group "modifiers" list {
3284 group "Elm_Config_Binding_Modifier" struct {
3285 value "mod" string: "Control";
3286 value "flag" uchar: 1;
3287 }
3288 }
3289 }
3290 group "Elm_Config_Binding_Key" struct {
3291 value "context" int: 0;
3292 value "key" string: "v";
3293 value "action" string: "paste";
3294 value "params" string: "";
3295 group "modifiers" list {
3296 group "Elm_Config_Binding_Modifier" struct {
3297 value "mod" string: "Control";
3298 value "flag" uchar: 1;
3299 }
3300 }
3301 }
3302 group "Elm_Config_Binding_Key" struct {
3303 value "context" int: 0;
3304 value "key" string: "menu";
3305 value "action" string: "menu";
3306 value "params" string: "";
3307 }
3308 }
3309 }
3263 } 3310 }
3264} 3311}
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)