diff options
author | Michael Dankov <tryagain@navit-project.org> | 2016-07-10 22:13:25 +0300 |
---|---|---|
committer | Michael Dankov <tryagain@navit-project.org> | 2016-07-10 22:13:25 +0300 |
commit | b0644d54c0eed934055593da50155cbd0e10b261 (patch) | |
tree | 1e202fb48089d72885524c95c1f9492872201657 /navit/gui | |
parent | 63b6e0291cca3477f701d02f273f96c065b23f70 (diff) | |
download | navit-b0644d54c0eed934055593da50155cbd0e10b261.tar.gz |
fix:gui_internal:Properly switch keyboard to lower/uppercaseR6698
Do the automatic switch in gui_internal_keypress_do instead of
gui_internal_search_changed so that other text input widgets would benefit,
e.g. poi search.
Diffstat (limited to 'navit/gui')
-rw-r--r-- | navit/gui/internal/gui_internal.c | 7 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal_keyboard.c | 42 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal_search.c | 4 |
3 files changed, 36 insertions, 17 deletions
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c index 2437ddee5..cf7db42a7 100644 --- a/navit/gui/internal/gui_internal.c +++ b/navit/gui/internal/gui_internal.c @@ -88,6 +88,7 @@ #include "gui_internal_gesture.h" #include "gui_internal_poi.h" #include "gui_internal_command.h" +#include "gui_internal_keyboard.h" /** @@ -1672,9 +1673,15 @@ gui_internal_keypress_do(struct gui_priv *this, char *key) dbg(lvl_info,"wi->state=0x%x\n", wi->state); } text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key); + + gui_internal_keyboard_to_lower_case(this); } g_free(wi->text); wi->text=text; + + if(!wi->text || !*wi->text) + gui_internal_keyboard_to_upper_case(this); + if (wi->func) { wi->reason=gui_internal_reason_keypress; wi->func(this, wi, wi->data); diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c index 7b51da546..3dc6ae556 100644 --- a/navit/gui/internal/gui_internal_keyboard.c +++ b/navit/gui/internal/gui_internal_keyboard.c @@ -12,6 +12,13 @@ #include "gui_internal_menu.h" #include "gui_internal_keyboard.h" +/** + * @brief Switch keyboard mode to uppercase if it's in lowercase mode and {@code VKBD_MODE_2} is set. + * + * Called when there's no input left in the input field. + * + * @param this The internal GUI instance + */ void gui_internal_keyboard_to_upper_case(struct gui_priv *this) { @@ -19,16 +26,24 @@ gui_internal_keyboard_to_upper_case(struct gui_priv *this) if (!this->keyboard) return; + md=gui_internal_menu_data(this); - // Switch to lowercase after the first key is pressed - if (md->keyboard_mode == 10) // Latin - gui_internal_keyboard_do(this, md->keyboard, 2); - if (md->keyboard_mode == 34) // Umlaut - gui_internal_keyboard_do(this, md->keyboard, 26); - if (md->keyboard_mode == 50) // Russian/Ukrainian/Belorussian - gui_internal_keyboard_do(this, md->keyboard, 42); + + if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2)) + gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2); + if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2)) + gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2); + if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2)) + gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2); } +/** + * @brief Switch keyboard mode to lowercase if it's in uppercase mode and {@code VKBD_MODE_2} is set. + * + * Called on each alphanumeric input. + * + * @param this The internal GUI instance + */ void gui_internal_keyboard_to_lower_case(struct gui_priv *this) { @@ -36,21 +51,22 @@ gui_internal_keyboard_to_lower_case(struct gui_priv *this) if (!this->keyboard) return; + md=gui_internal_menu_data(this); - // Switch to lowercase after the first key is pressed - if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2)) // Latin + + if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2)) gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2); - if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2)) // Umlaut + if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2)) gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2); - if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2)) // Russian/Ukrainian/Belorussian + if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2)) gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2); } /** * @brief Processes a key press on the internal GUI keyboard * - * If the keyboard is currently in uppercase mode and {@code VKBD_MODE_2} is set, it is then switched to - * the corresponding lowercase mode. + * If the keyboard is currently in uppercase mode and {@code VKBD_MODE_2} is set, it is tswitched to + * the corresponding lowercase mode in {@code gui_internal_keypress_do}. * * @param this The internal GUI instance * @param wm diff --git a/navit/gui/internal/gui_internal_search.c b/navit/gui/internal/gui_internal_search.c index 09b7bc38a..e5e137e07 100644 --- a/navit/gui/internal/gui_internal_search.c +++ b/navit/gui/internal/gui_internal_search.c @@ -434,13 +434,9 @@ gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data search_attr.type=attr_house_number; search_attr.u.str=wm->text; search_list_search(this->sl, &search_attr, 1); - // Text is not necessarily entered via the on-screen keyboard, - // but we now switch it to lower case anyway. - gui_internal_keyboard_to_lower_case(this); gui_internal_search_idle_start(this, wm->name, search_list, param); } else { // If not enough content is entered, we highlight all keys. - gui_internal_keyboard_to_upper_case(this); gui_internal_highlight_possible_keys(this, ""); } l=g_list_last(this->root.children); |