diff --git a/distribution/changelog.txt b/distribution/changelog.txt index bbf479f5fa..d41ec7a2df 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -12,6 +12,7 @@ - Fix: [#20255] Images from the last hovered-over coaster in the object selection are not freed. - Fix: [#20616] Confirmation button in the track designer’s quit prompt has the wrong text. - Fix: [#20628] Moving caret using Ctrl+left can move too far when using a multibyte grapheme. +- Fix: [#20631] IME window not positioned correctly. - Fix: [#20845] Trying to save under a folder with no write permissions causes a crash. - Fix: [#21054] “No entrance” style is selected by default in the track designer. - Fix: [#21145] [Plugin] setInterval/setTimeout handle conflict. diff --git a/src/openrct2-ui/TextComposition.cpp b/src/openrct2-ui/TextComposition.cpp index 48f26c3d25..e33d0c8035 100644 --- a/src/openrct2-ui/TextComposition.cpp +++ b/src/openrct2-ui/TextComposition.cpp @@ -38,11 +38,7 @@ bool TextComposition::IsActive() TextInputSession* TextComposition::Start(u8string& buffer, size_t maxLength) { - // TODO This doesn't work, and position could be improved to where text entry is - SDL_Rect rect = { 10, 10, 100, 100 }; - SDL_SetTextInputRect(&rect); SDL_StartTextInput(); - _session.Buffer = &buffer; _session.MaxLength = maxLength; _session.SelectionStart = buffer.size(); diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index 57cc5e07cc..c6dea3ad2b 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -7,6 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include #include #include #include @@ -291,7 +292,7 @@ public: // IME composition if (!String::IsNullOrEmpty(gTextInput->ImeBuffer)) { - DrawIMEComposition(dpi, cursorX, cursorY); + IMEComposition(cursorX, cursorY); } } @@ -316,18 +317,10 @@ public: } private: - static void DrawIMEComposition(DrawPixelInfo& dpi, int32_t cursorX, int32_t cursorY) + static void IMEComposition(int32_t cursorX, int32_t cursorY) { - int compositionWidth = GfxGetStringWidth(gTextInput->ImeBuffer, FontStyle::Medium); - ScreenCoordsXY screenCoords(cursorX - (compositionWidth / 2), cursorY + 13); - int width = compositionWidth; - int height = 10; - - GfxFillRect( - dpi, { screenCoords - ScreenCoordsXY{ 1, 1 }, screenCoords + ScreenCoordsXY{ width + 1, height + 1 } }, - PALETTE_INDEX_12); - GfxFillRect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ width, height } }, PALETTE_INDEX_0); - GfxDrawString(dpi, screenCoords, static_cast(gTextInput->ImeBuffer), { COLOUR_DARK_GREEN }); + SDL_Rect rect = { cursorX, cursorY, 100, 100 }; + SDL_SetTextInputRect(&rect); } void ExecuteCallback(bool hasValue)