Skip to content

Commit

Permalink
SetIMETextInputRectangle on window resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
SadPencil committed Feb 2, 2025
1 parent 7b6a818 commit b3fa88e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ClientGUI/IME/IMEHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ protected virtual void OnIMETextInput(char character)
}
}

public void SetIMETextInputRectangle(WindowManager manager)
{
if (manager.SelectedControl is XNATextBox textBox)
SetIMETextInputRectangle(textBox);
}

private void SetIMETextInputRectangle(XNATextBox sender)
{
WindowManager windowManager = sender.WindowManager;
Expand All @@ -122,7 +128,7 @@ private void SetIMETextInputRectangle(XNATextBox sender)
// Therefore, unless whenever InputPosition is changed, SetIMETextInputRectangle() is raised
// -- which requires more time to investigate and test, it's commented out for now.
//var vec = Renderer.GetTextDimensions(
// sender.Text.Substring(sender.TextStartPosition, sender.TextEndPosition - sender.InputPosition),
// sender.Text.Substring(sender.TextStartPosition, sender.InputPosition),
// sender.FontIndex);
//rect.X += (int)(vec.X * scaleRatio);

Expand Down
8 changes: 7 additions & 1 deletion DXMainClient/DXGUI/GameClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ protected override void Initialize()

WindowManager wm = new(this, graphics);
wm.Initialize(content, ProgramConstants.GetBaseResourcePath());
wm.IMEHandler = IMEHandler.Create(this);
IMEHandler imeHandler = IMEHandler.Create(this);
wm.IMEHandler = imeHandler;

wm.ControlINIAttributeParsers.Add(new TranslationINIParser());

Expand Down Expand Up @@ -190,6 +191,11 @@ protected override void Initialize()
// SetGraphicsMode(wm, currentWindowSize.Width, currentWindowSize.Height, centerOnScreen: false);
// }
//};

wm.WindowSizeChangedByUser += (sender, e) =>
{
imeHandler.SetIMETextInputRectangle(wm);
};
}
#endif

Expand Down

0 comments on commit b3fa88e

Please sign in to comment.