Reconfigure 'select all' for texts in macOS.
Use the idiomatic combination. Update reference to particular comment line of 'src/widgets/textbox.cpp' in comment with the current line where the comment is now. Remove `unsigned` as the type for `copypaste_modifier`, because it was a little bit less future proof that way, it is better as an `SDL_Keycode`, which at the moment is `Sint32`, which in turn is `int32_t` ultimately. Reuse the constant for 'select all' so renaming it to `modifier_key`.
This commit is contained in:
parent
0cb203e9c0
commit
48ec4cd6f7
1 changed files with 17 additions and 9 deletions
|
@ -476,13 +476,21 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,
|
|||
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
// For copy/paste we use a different key on the MAC. Other ctrl modifiers won't
|
||||
// be modifed seems not to be required when I read the comment in
|
||||
// widgets/textbox.cpp:516. Would be nice if somebody on a MAC would test it.
|
||||
/*
|
||||
* For copy, cut and paste we use a different key on the MAC. Even for 'select
|
||||
* all', contradicting the comment in widgets/textbox.cpp:495.
|
||||
*
|
||||
* The reason for that is, by coupling 'select all' to the behavior for copy,
|
||||
* cut and paste, the text box behavior as a whole gets consistent with default
|
||||
* macOS hotkey idioms.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
const unsigned copypaste_modifier = KMOD_LGUI | KMOD_RGUI;
|
||||
// Idiomatic modifier key in macOS computers.
|
||||
const SDL_Keycode modifier_key = KMOD_GUI;
|
||||
#else
|
||||
const unsigned copypaste_modifier = KMOD_CTRL;
|
||||
// Idiomatic modifier key in Microsoft desktop environments. Common in
|
||||
// GNU/Linux as well, to some extent.
|
||||
const SDL_Keycode modifier_key = KMOD_CTRL;
|
||||
#endif
|
||||
|
||||
switch(key) {
|
||||
|
@ -512,7 +520,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,
|
|||
break;
|
||||
|
||||
case SDLK_a:
|
||||
if(!(modifier & KMOD_CTRL)) {
|
||||
if(!(modifier & modifier_key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -536,7 +544,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,
|
|||
break;
|
||||
|
||||
case SDLK_c:
|
||||
if(!(modifier & copypaste_modifier)) {
|
||||
if(!(modifier & modifier_key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -547,7 +555,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,
|
|||
break;
|
||||
|
||||
case SDLK_x:
|
||||
if(!(modifier & copypaste_modifier)) {
|
||||
if(!(modifier & modifier_key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -557,7 +565,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,
|
|||
break;
|
||||
|
||||
case SDLK_v:
|
||||
if(!(modifier & copypaste_modifier)) {
|
||||
if(!(modifier & modifier_key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue