forked from enlightenment/efl
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
This commit is contained in:
parent
1587d7fa1b
commit
a92f8c210b
|
@ -1,5 +1,5 @@
|
||||||
group "Elm_Config" struct {
|
group "Elm_Config" struct {
|
||||||
value "config_version" int: 131094;
|
value "config_version" int: 131095;
|
||||||
value "entry_select_allow" uchar: 1;
|
value "entry_select_allow" uchar: 1;
|
||||||
value "engine" string: "";
|
value "engine" string: "";
|
||||||
value "vsync" uchar: 0;
|
value "vsync" uchar: 0;
|
||||||
|
@ -3275,7 +3275,54 @@ group "Elm_Config" struct {
|
||||||
value "action" string: "move";
|
value "action" string: "move";
|
||||||
value "params" string: "next";
|
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: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
group "Elm_Config" struct {
|
group "Elm_Config" struct {
|
||||||
value "config_version" int: 131094;
|
value "config_version" int: 131095;
|
||||||
value "entry_select_allow" uchar: 1;
|
value "entry_select_allow" uchar: 1;
|
||||||
value "engine" string: "";
|
value "engine" string: "";
|
||||||
value "vsync" uchar: 0;
|
value "vsync" uchar: 0;
|
||||||
|
@ -3261,7 +3261,54 @@ group "Elm_Config" struct {
|
||||||
value "action" string: "move";
|
value "action" string: "move";
|
||||||
value "params" string: "next";
|
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: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
group "Elm_Config" struct {
|
group "Elm_Config" struct {
|
||||||
value "config_version" int: 131094;
|
value "config_version" int: 131095;
|
||||||
value "entry_select_allow" uchar: 1;
|
value "entry_select_allow" uchar: 1;
|
||||||
value "engine" string: "";
|
value "engine" string: "";
|
||||||
value "vsync" uchar: 0;
|
value "vsync" uchar: 0;
|
||||||
|
@ -3258,7 +3258,54 @@ group "Elm_Config" struct {
|
||||||
value "action" string: "move";
|
value "action" string: "move";
|
||||||
value "params" string: "next";
|
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: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 _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 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
|
static void
|
||||||
_efl_ui_textbox_guide_update(Evas_Object *obj,
|
_efl_ui_textbox_guide_update(Evas_Object *obj,
|
||||||
Eina_Bool has_text)
|
Eina_Bool has_text)
|
||||||
|
@ -1050,49 +1063,38 @@ _long_press_cb(void *data, const Efl_Event *ev EINA_UNUSED)
|
||||||
sd->long_pressed = EINA_TRUE;
|
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);
|
efl_ui_textbox_selection_copy(obj);
|
||||||
Eina_Bool on_hold = EINA_FALSE;
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* First check if context menu disabled is false or not, and
|
static Eina_Bool
|
||||||
* then check for key id */
|
_key_action_cut(Evas_Object *obj, const char *params EINA_UNUSED)
|
||||||
if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu"))
|
{
|
||||||
|
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);
|
_menu_call(obj);
|
||||||
on_hold = EINA_TRUE;
|
b_ret = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else
|
return b_ret;
|
||||||
{
|
|
||||||
#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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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_event_callback_add(sd->entry_edje, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED,
|
||||||
_efl_ui_textbox_move_cb, obj);
|
_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
|
efl_event_callback_add
|
||||||
(sd->entry_edje, EFL_EVENT_POINTER_DOWN, _mouse_down_cb, obj);
|
(sd->entry_edje, EFL_EVENT_POINTER_DOWN, _mouse_down_cb, obj);
|
||||||
efl_event_callback_add
|
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;
|
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_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_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)
|
ELM_PART_OVERRIDE_TEXT_GET(efl_ui_textbox, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data)
|
||||||
|
|
|
@ -92,6 +92,7 @@ class @beta Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements Efl.Input.Click
|
||||||
Efl.Canvas.Group.group_calculate;
|
Efl.Canvas.Group.group_calculate;
|
||||||
Efl.Ui.Widget.on_access_activate;
|
Efl.Ui.Widget.on_access_activate;
|
||||||
Efl.Ui.Widget.theme_apply;
|
Efl.Ui.Widget.theme_apply;
|
||||||
|
Efl.Ui.Widget.widget_input_event_handler;
|
||||||
Efl.Ui.Focus.Object.on_focus_update;
|
Efl.Ui.Focus.Object.on_focus_update;
|
||||||
Efl.Ui.Widget.interest_region { get; }
|
Efl.Ui.Widget.interest_region { get; }
|
||||||
Efl.Ui.Widget.disabled {set;}
|
Efl.Ui.Widget.disabled {set;}
|
||||||
|
|
|
@ -2474,6 +2474,12 @@ _config_update(void)
|
||||||
tcfg = _config_system_load();
|
tcfg = _config_system_load();
|
||||||
IFCFGEND
|
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.
|
* Fix user config for current ELM_CONFIG_EPOCH here.
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -271,7 +271,7 @@ struct _Efl_Ui_Theme_Data
|
||||||
* the users config doesn't need to be wiped - simply new values need
|
* the users config doesn't need to be wiped - simply new values need
|
||||||
* to be put in
|
* 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_EPOCH_OFFSET 16
|
||||||
# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
|
# define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
|
||||||
ELM_CONFIG_FILE_GENERATION)
|
ELM_CONFIG_FILE_GENERATION)
|
||||||
|
|
Loading…
Reference in New Issue