forked from enlightenment/efl
text/entry: add more key controls for os x
In OS X, cmd-c,v, ... keys are used instead of ctrl-c,v..., this patch adapts these key handlings.
This commit is contained in:
parent
db8b0020ec
commit
cc7dbde840
|
@ -1679,6 +1679,9 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
Edje_Real_Part *rp = ed->focused_part;
|
Edje_Real_Part *rp = ed->focused_part;
|
||||||
Entry *en;
|
Entry *en;
|
||||||
Eina_Bool control, alt, shift;
|
Eina_Bool control, alt, shift;
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
Eina_Bool super, altgr;
|
||||||
|
#endif
|
||||||
Eina_Bool multiline;
|
Eina_Bool multiline;
|
||||||
Eina_Bool cursor_changed;
|
Eina_Bool cursor_changed;
|
||||||
int old_cur_pos;
|
int old_cur_pos;
|
||||||
|
@ -1712,6 +1715,10 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
|
|
||||||
old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
|
old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
||||||
|
altgr = evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
||||||
|
#endif
|
||||||
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
||||||
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
||||||
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
||||||
|
@ -1824,8 +1831,12 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
}
|
}
|
||||||
if (evas_textblock_cursor_char_prev(en->cursor))
|
if (evas_textblock_cursor_char_prev(en->cursor))
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (altgr) evas_textblock_cursor_word_start(en->cursor);
|
||||||
|
#else
|
||||||
/* If control is pressed, go to the start of the word */
|
/* If control is pressed, go to the start of the word */
|
||||||
if (control) evas_textblock_cursor_word_start(en->cursor);
|
if (control) evas_textblock_cursor_word_start(en->cursor);
|
||||||
|
#endif
|
||||||
if (en->select_allow)
|
if (en->select_allow)
|
||||||
{
|
{
|
||||||
if (shift) _sel_extend(ed, en->cursor, rp->object, en);
|
if (shift) _sel_extend(ed, en->cursor, rp->object, en);
|
||||||
|
@ -1861,7 +1872,11 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If control is pressed, go to the end of the word */
|
/* If control is pressed, go to the end of the word */
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (altgr) evas_textblock_cursor_word_end(en->cursor);
|
||||||
|
#else
|
||||||
if (control) evas_textblock_cursor_word_end(en->cursor);
|
if (control) evas_textblock_cursor_word_end(en->cursor);
|
||||||
|
#endif
|
||||||
if (evas_textblock_cursor_char_next(en->cursor))
|
if (evas_textblock_cursor_char_next(en->cursor))
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
if (en->select_allow)
|
if (en->select_allow)
|
||||||
|
@ -1990,14 +2005,22 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
_edje_emit(ed, "cursor,changed,manual", rp->part->name);
|
_edje_emit(ed, "cursor,changed,manual", rp->part->name);
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (!shift) && (!strcmp(ev->keyname, "v")))
|
||||||
|
#else
|
||||||
else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
|
else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
_edje_emit(ed, "entry,paste,request", rp->part->name);
|
_edje_emit(ed, "entry,paste,request", rp->part->name);
|
||||||
_edje_emit(ed, "entry,paste,request,3", rp->part->name);
|
_edje_emit(ed, "entry,paste,request,3", rp->part->name);
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (!strcmp(ev->keyname, "a")))
|
||||||
|
#else
|
||||||
else if ((control) && (!strcmp(ev->keyname, "a")))
|
else if ((control) && (!strcmp(ev->keyname, "a")))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
if (shift)
|
if (shift)
|
||||||
|
@ -2011,19 +2034,31 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
|
||||||
|
#else
|
||||||
else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
|
else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
_edje_emit(ed, "entry,copy,notify", rp->part->name);
|
_edje_emit(ed, "entry,copy,notify", rp->part->name);
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
|
||||||
|
#else
|
||||||
else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
|
else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
_edje_emit(ed, "entry,cut,notify", rp->part->name);
|
_edje_emit(ed, "entry,cut,notify", rp->part->name);
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (!strcmp(ev->keyname, "z")))
|
||||||
|
#else
|
||||||
else if ((control) && (!strcmp(ev->keyname, "z")))
|
else if ((control) && (!strcmp(ev->keyname, "z")))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
if (shift)
|
if (shift)
|
||||||
|
@ -2038,7 +2073,11 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
}
|
}
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
else if ((super) && (!shift) && (!strcmp(ev->keyname, "y")))
|
||||||
|
#else
|
||||||
else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
|
else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
// redo
|
// redo
|
||||||
|
|
|
@ -702,6 +702,9 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
Evas_Event_Key_Down *ev = event_info;
|
Evas_Event_Key_Down *ev = event_info;
|
||||||
Efl_Canvas_Text_Cursor *cur;
|
Efl_Canvas_Text_Cursor *cur;
|
||||||
Eina_Bool control, alt, shift;
|
Eina_Bool control, alt, shift;
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
Eina_Bool super, altgr;
|
||||||
|
#endif
|
||||||
Eina_Bool multiline;
|
Eina_Bool multiline;
|
||||||
int old_cur_pos;
|
int old_cur_pos;
|
||||||
char *string = (char *)ev->string;
|
char *string = (char *)ev->string;
|
||||||
|
@ -720,6 +723,10 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
||||||
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
||||||
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
||||||
|
altgr = evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
||||||
|
#endif
|
||||||
multiline = en->multiline;
|
multiline = en->multiline;
|
||||||
|
|
||||||
/* Translate some keys to strings. */
|
/* Translate some keys to strings. */
|
||||||
|
@ -788,8 +795,12 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
_key_down_sel_pre(obj, cur, en, shift, EINA_FALSE);
|
_key_down_sel_pre(obj, cur, en, shift, EINA_FALSE);
|
||||||
|
|
||||||
efl_canvas_text_cursor_char_prev(cur);
|
efl_canvas_text_cursor_char_prev(cur);
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (altgr) efl_canvas_text_cursor_word_start(cur);
|
||||||
|
#else
|
||||||
/* If control is pressed, go to the start of the word */
|
/* If control is pressed, go to the start of the word */
|
||||||
if (control) efl_canvas_text_cursor_word_start(cur);
|
if (control) efl_canvas_text_cursor_word_start(cur);
|
||||||
|
#endif
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
|
|
||||||
_key_down_sel_post(obj, cur, en, shift);
|
_key_down_sel_post(obj, cur, en, shift);
|
||||||
|
@ -800,8 +811,12 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
_key_down_sel_pre(obj, cur, en, shift, EINA_TRUE);
|
_key_down_sel_pre(obj, cur, en, shift, EINA_TRUE);
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (altgr) efl_canvas_text_cursor_word_end(cur);
|
||||||
|
#else
|
||||||
/* If control is pressed, go to the end of the word */
|
/* If control is pressed, go to the end of the word */
|
||||||
if (control) efl_canvas_text_cursor_word_end(cur);
|
if (control) efl_canvas_text_cursor_word_end(cur);
|
||||||
|
#endif
|
||||||
efl_canvas_text_cursor_char_next(cur);
|
efl_canvas_text_cursor_char_next(cur);
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
|
|
||||||
|
@ -962,9 +977,16 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
free(compres);
|
free(compres);
|
||||||
compres = NULL;
|
compres = NULL;
|
||||||
_compose_seq_reset(en);
|
_compose_seq_reset(en);
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (super ||
|
||||||
|
(string && (!string[1]) &&
|
||||||
|
(string[0] != 0xa) && (string[0] != 0x9) &&
|
||||||
|
((string[0] < 0x20) || (string[0] == 0x7f))))
|
||||||
|
#else
|
||||||
if (string && (!string[1]) &&
|
if (string && (!string[1]) &&
|
||||||
(string[0] != 0xa) && (string[0] != 0x9) &&
|
(string[0] != 0xa) && (string[0] != 0x9) &&
|
||||||
((string[0] < 0x20) || (string[0] == 0x7f)))
|
((string[0] < 0x20) || (string[0] == 0x7f)))
|
||||||
|
#endif
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1844,7 +1844,11 @@ _key_down_cb(void *data,
|
||||||
}
|
}
|
||||||
else
|
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");
|
Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Ctrl operations */
|
/* Ctrl operations */
|
||||||
if (control)
|
if (control)
|
||||||
|
|
|
@ -1462,7 +1462,11 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
|
||||||
|
|
||||||
_elm_code_widget_update_focus_directions((Elm_Code_Widget *)obj);
|
_elm_code_widget_update_focus_directions((Elm_Code_Widget *)obj);
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
if (evas_key_modifier_is_set(ev->modifiers, "Super"))
|
||||||
|
#else
|
||||||
if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_elm_code_widget_control_key_down_cb(widget, ev->key);
|
_elm_code_widget_control_key_down_cb(widget, ev->key);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue