Skip to content

Fix IME candidate window position for text fields - #399

Merged
Dream-Master merged 3 commits into
GTNewHorizons:masterfrom
sivaDog:fix/ime-text-input-area
Nov 24, 2026
Merged

Dream-Master merged 3 commits into
GTNewHorizons:masterfrom
sivaDog:fix/ime-text-input-area

Conversation

@sivaDog

@sivaDog sivaDog commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #371

Pass the position of the focused text field to SDL, so the IME candidate window shows up next to where you are typing.

Changes:

  • Send the focused GuiTextField's rect and caret position with SDL_SetTextInputArea
  • Clear the area on screens without a GuiTextField (signs, books, etc. stay at the top-left as before)
  • Don't crash on a GuiTextField whose font renderer is null (NEI's recipe search field)

Tested on GTNH 2.9.1 (Windows 11, Microsoft IME, Java 25):

  • The candidate window appears next to the field in chat, NEI, AE2 terminals, the anvil, and others
  • The position stays correct after toggling F11 and after moving the window to another monitor

Limitations:

  • In exclusive fullscreen (borderless=false) the candidate window is not shown at all (same as before this change). It shows with borderless=true.
  • Text inputs that don't use GuiTextField (signs, books, BetterQuesting, etc.) are not covered.
  • Fields drawn with a translated position (e.g. NEI's options screen) get the wrong position.
  • Microsoft IME commits the composition text that overflows the rect, so in narrow fields you can't type a long phrase before converting it.
  • Not tested on Linux or macOS.

Checklist

  • I have tested this PR in DevEnv
  • I have tested this PR in Fullpack
  • This PR is in compliance with the GTNH AI Policy
  • This PR requires another PR in order to merge

@sivaDog
sivaDog force-pushed the fix/ime-text-input-area branch from 2ab249b to 31a1b9b Compare November 22, 2026 07:41
@sivaDog
sivaDog requested a review from a team November 24, 2026 13:04
@Chitak985 Chitak985 added the Bug Fix Fixes a bug. Please link it in the PR if an issue exists for it. label Nov 24, 2026

@Chitak985 Chitak985 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally to the issues, you (or someone else) should test it on linux and mac os.

@sivaDog

sivaDog commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I fixed both points in dc95e23.

I also tested it on Linux:

  • Ubuntu 22.04, GNOME on X11, IBus + Mozc 2.26
  • Dev environment (runClient)

The candidate window shows up right below the text field in the world name field, chat, creative search and NEI search. SDL_SetTextInputArea() returned true every time. Signs are not a GuiTextField, so the area is cleared and IBus uses its default position.

On IBus, the composition text is shown in the candidate window instead of the text field. This is because lwjgl3ify doesn't set SDL_HINT_IME_IMPLEMENTED_UI, and it was the same before this PR.

linux-world-name linux-chat
linux-nei-search

I don't have a Mac, and I couldn't test Wayland (the pixel density stays 1.0 on X11). It would be great if someone could test those.

@Chitak985 Chitak985 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything's good now

@Chitak985 Chitak985 added the Frozen PR PRs that are frozen until further notice; the NH team will discuss what to do with it. label Nov 24, 2026
@Dream-Master
Dream-Master merged commit abc5a05 into GTNewHorizons:master Nov 24, 2026
1 check passed
@Chitak985

Copy link
Copy Markdown
Member

Froze the PR so it doesn't get merged in case Mac testing is required

@Chitak985

Copy link
Copy Markdown
Member

oh

@Dream-Master

Copy link
Copy Markdown
Member

oh to late . sorry didnt see the tag

@Dream-Master

Copy link
Copy Markdown
Member

should i test it in full pack ?

@Chitak985

Copy link
Copy Markdown
Member

it's probably fine tbh

@Chitak985

Copy link
Copy Markdown
Member

do you have a Mac?

@Dream-Master

Copy link
Copy Markdown
Member

no sadly not

@Chitak985

Copy link
Copy Markdown
Member

Windows and Linux both work so I think it's fine

@Dream-Master

Copy link
Copy Markdown
Member

we an ship it and when we get a bug report from mac user we can revert it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Fixes a bug. Please link it in the PR if an issue exists for it. Frozen PR PRs that are frozen until further notice; the NH team will discuss what to do with it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IME candidate / preedit window is stuck at the top-left corner: SDL_SetTextInputArea is never called

3 participants