diff --git a/src/lang/english.txt b/src/lang/english.txt index e613f4b191..33564eebb1 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1332,6 +1332,12 @@ STR_CONFIG_SETTING_SCROLLWHEEL_SCROLL :Scroll map STR_CONFIG_SETTING_SCROLLWHEEL_OFF :Off STR_CONFIG_SETTING_SCROLLWHEEL_MULTIPLIER :Map scrollwheel speed: {STRING2} STR_CONFIG_SETTING_SCROLLWHEEL_MULTIPLIER_HELPTEXT :Control the sensitivity of mouse-wheel scrolling +STR_CONFIG_SETTING_OSK_ACTIVATION :On screen keyboard: {STRING2} +STR_CONFIG_SETTING_OSK_ACTIVATION_HELPTEXT :Select the method to open the on screen keyboard for entering text into editboxes only using the pointing device. This is meant for small devices without actual keyboard +STR_CONFIG_SETTING_OSK_ACTIVATION_DISABLED :Disabled +STR_CONFIG_SETTING_OSK_ACTIVATION_DOUBLE_CLICK :Double click +STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK_FOCUS :Single click (when focussed) +STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK :Single click (immediately) STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU :Right-click emulation: {STRING2} STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_HELPTEXT :Select the method to emulate right mouse-button clicks diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 3a87437d73..9c90b927ad 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -30,6 +30,15 @@ #include "table/strings.h" +/** Method to open the OSK. */ +enum OskActivation { + OSKA_DISABLED, ///< The OSK shall not be activated at all. + OSKA_DOUBLE_CLICK, ///< Double click on the edit box opens OSK. + OSKA_SINGLE_CLICK, ///< Single click after focus click opens OSK. + OSKA_IMMEDIATELY, ///< Focussing click already opens OSK. +}; + + static const NWidgetPart _nested_land_info_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), @@ -835,8 +844,10 @@ void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bo return; } - if (!focus_changed && w->window_class != WC_OSK) { - /* Open the OSK window if clicked on an edit box, while not changing focus */ + if (w->window_class != WC_OSK && _settings_client.gui.osk_activation != OSKA_DISABLED && + (!focus_changed || _settings_client.gui.osk_activation == OSKA_IMMEDIATELY) && + (click_count == 2 || _settings_client.gui.osk_activation != OSKA_DOUBLE_CLICK)) { + /* Open the OSK window */ ShowOnScreenKeyboard(w, wid); } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4c5eaca1ca..530dc64728 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1728,6 +1728,7 @@ static SettingEntry _settings_ui_interaction[] = { * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */ SettingEntry("gui.scrollwheel_scrolling"), SettingEntry("gui.scrollwheel_multiplier"), + SettingEntry("gui.osk_activation"), #ifdef __APPLE__ /* We might need to emulate a right mouse button on mac */ SettingEntry("gui.right_mouse_btn_emulation"), diff --git a/src/settings_type.h b/src/settings_type.h index 8a34104fde..af71b2b971 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -117,6 +117,7 @@ struct GUISettings { uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan byte missing_strings_threshold; ///< the number of missing strings before showing the warning uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis + uint8 osk_activation; ///< Mouse gesture to trigger the OSK. uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini index b80f195c72..0b2fb372be 100644 --- a/src/table/gameopt_settings.ini +++ b/src/table/gameopt_settings.ini @@ -22,6 +22,7 @@ static const char *_savegame_date = "long|short|iso"; #ifdef ENABLE_NETWORK static const char *_server_langs = "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN"; #endif /* ENABLE_NETWORK */ +static const char *_osk_activation = "disabled|double|single|immediately"; static const SettingDesc _gameopt_settings[] = { /* In version 4 a new difficulty setting has been added to the difficulty settings, diff --git a/src/table/settings.ini b/src/table/settings.ini index 12157d1a85..a9caf1caa7 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -2324,6 +2324,20 @@ str = STR_CONFIG_SETTING_HOVER_DELAY strhelp = STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT strval = STR_CONFIG_SETTING_HOVER_DELAY_VALUE +[SDTC_OMANY] +var = gui.osk_activation +type = SLE_UINT8 +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +str = STR_CONFIG_SETTING_OSK_ACTIVATION +strhelp = STR_CONFIG_SETTING_OSK_ACTIVATION_HELPTEXT +strval = STR_CONFIG_SETTING_OSK_ACTIVATION_DISABLED +guiflags = SGF_MULTISTRING +full = _osk_activation +def = 1 +min = 0 +max = 3 +cat = SC_BASIC + [SDTC_VAR] var = gui.toolbar_pos type = SLE_UINT8