mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 14:54:30 +01:00
Fix #3062: Backtick ` opens console when inputting text into chat or other things
For some reason SDL_IsTextInputActive() returns SDL_TRUE before any call to SDL_StartTextInput(). This may be an SDL bug, but I've worked around it for this feature by also checking if there is a valid gTextInput.buffer. I've made an exception for the console itself, where the backtick should probably continue to close it.
This commit is contained in:
committed by
Ted John
parent
0f695b3120
commit
55d3ab8cc8
@@ -1431,7 +1431,7 @@ void title_handle_keyboard_input()
|
||||
|
||||
// Reserve backtick for console
|
||||
if (key == SDL_SCANCODE_GRAVE) {
|
||||
if (gConfigGeneral.debugging_tools || gConsoleOpen) {
|
||||
if ((gConfigGeneral.debugging_tools && !platform_is_input_active()) || gConsoleOpen) {
|
||||
window_cancel_textbox();
|
||||
console_toggle();
|
||||
}
|
||||
@@ -1502,7 +1502,7 @@ void game_handle_keyboard_input()
|
||||
|
||||
// Reserve backtick for console
|
||||
if (key == SDL_SCANCODE_GRAVE) {
|
||||
if (gConfigGeneral.debugging_tools || gConsoleOpen) {
|
||||
if ((gConfigGeneral.debugging_tools && !platform_is_input_active()) || gConsoleOpen) {
|
||||
window_cancel_textbox();
|
||||
console_toggle();
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ void platform_process_messages();
|
||||
int platform_scancode_to_rct_keycode(int sdl_key);
|
||||
void platform_start_text_input(utf8 *buffer, int max_length);
|
||||
void platform_stop_text_input();
|
||||
bool platform_is_input_active();
|
||||
void platform_get_date_utc(rct2_date *out_date);
|
||||
void platform_get_time_utc(rct2_time *out_time);
|
||||
void platform_get_date_local(rct2_date *out_date);
|
||||
|
||||
@@ -652,6 +652,11 @@ void platform_start_text_input(utf8* buffer, int max_length)
|
||||
textinputbuffer_init(&gTextInput, buffer, max_length);
|
||||
}
|
||||
|
||||
bool platform_is_input_active()
|
||||
{
|
||||
return SDL_IsTextInputActive() && gTextInput.buffer != NULL;
|
||||
}
|
||||
|
||||
void platform_stop_text_input()
|
||||
{
|
||||
SDL_StopTextInput();
|
||||
|
||||
Reference in New Issue
Block a user