|
5 | 5 |
|
6 | 6 | using Microsoft.Xna.Framework; |
7 | 7 |
|
| 8 | +using Rampastring.XNAUI; |
8 | 9 | using Rampastring.XNAUI.Input; |
9 | 10 | using Rampastring.XNAUI.XNAControls; |
10 | 11 |
|
@@ -89,17 +90,26 @@ protected virtual void OnIMETextInput(char character) |
89 | 90 |
|
90 | 91 | private void SetIMETextInputRectangle(XNATextBox sender) |
91 | 92 | { |
92 | | - var rect = sender.RenderRectangle(); |
93 | | - rect.X += sender.WindowManager.SceneXPosition; |
94 | | - rect.Y += sender.WindowManager.SceneYPosition; |
| 93 | + WindowManager windowManager = sender.WindowManager; |
95 | 94 |
|
96 | | - // Following the input cursor |
97 | | - // This requires SetIMETextInputRectangle() be called whenever InputPosition is changed. |
| 95 | + Rectangle textBoxRect = sender.RenderRectangle(); |
| 96 | + double scaleRatio = windowManager.ScaleRatio; |
98 | 97 |
|
| 98 | + Rectangle rect = new() |
| 99 | + { |
| 100 | + X = (int)(textBoxRect.X * scaleRatio + windowManager.SceneXPosition), |
| 101 | + Y = (int)(textBoxRect.Y * scaleRatio + windowManager.SceneYPosition), |
| 102 | + Width = (int)(textBoxRect.Width * scaleRatio), |
| 103 | + Height = (int)(textBoxRect.Height * scaleRatio) |
| 104 | + }; |
| 105 | + |
| 106 | + // The following code returns a more accurate location, aware of the input cursor |
| 107 | + // However, it requires SetIMETextInputRectangle() be called whenever InputPosition is changed. |
| 108 | + // And therefore, it's commented out for now. |
99 | 109 | //var vec = Renderer.GetTextDimensions( |
100 | 110 | // sender.Text.Substring(sender.TextStartPosition, sender.TextEndPosition - sender.InputPosition), |
101 | 111 | // sender.FontIndex); |
102 | | - //rect.X += (int)vec.X; |
| 112 | + //rect.X += (int)(vec.X * scaleRatio); |
103 | 113 |
|
104 | 114 | SetTextInputRectangle(rect); |
105 | 115 | } |
|
0 commit comments