#1078 TextBox masking in window mode.#1142
#1078 TextBox masking in window mode.#1142daneo1989 wants to merge 2 commits intoSuprcode:masterfrom
Conversation
[32 tools called] Windowed masking was still wrong because the WinForms `TextBox` keeps painting above the DirectX surface whenever the client isn’t in exclusive fullscreen (the root cause reported in [Crystal#1078](Suprcode#1078)). I now relocate the WinForms control off-screen while windowed and replay all mouse traffic into it so we can keep using its text-editing logic even though it’s no longer visible. That lets the Mir UI texture be the only thing you see in both modes. ```44:82:Client/MirControls/MirTextBox.cs protected override void OnLocationChanged() { base.OnLocationChanged(); if (TextBox != null && !TextBox.IsDisposed) UpdateTextBoxHostLocation(); TextureValid = false; Redraw(); } private void UpdateTextBoxHostLocation(bool force = false) { if (TextBox == null || TextBox.IsDisposed) return; bool hide = !Settings.FullScreen; ... TextBox.Location = hide ? HiddenTextBoxLocation : DisplayLocation; _textBoxOffscreen = hide; } ``` ```296:341:Client/MirControls/MirTextBox.cs public override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (_textBoxOffscreen && e.Button == MouseButtons.Left) { SetFocus(); ForwardMouseMessage(WM_LBUTTONDOWN, e); } } ... public override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); if (_textBoxOffscreen) ForwardMouseWheel(e); } ``` ```488:600:Client/MirControls/MirTextBox.cs private void ForwardMouseMessage(int message, MouseEventArgs e, bool includeCurrentButtons = false) { if (!_textBoxOffscreen || TextBox == null || TextBox.IsDisposed) return; ... SendMessage(TextBox.Handle, message, (IntPtr)wParam, (IntPtr)lParam); } ... [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); ``` Key points: - `UpdateTextBoxHostLocation` now centralizes where the WinForms input control lives. In fullscreen it sits where it always was; in windowed mode it’s moved to `HiddenTextBoxLocation` so it never paints over Mir UIs. - Mouse input paths (`OnMouseDown/Move/Up/DoubleClick/Wheel`) detect when the control is hidden and replay the corresponding Windows messages via `SendMessage`, using `CMain.MPoint` to compute the caret position. Keyboard input still flows through the real `TextBox`, so all selection/editing behavior is preserved without rewriting it manually. - Texture creation is still triggered everywhere (windowed + fullscreen), so the Mir-themed mask/caret drawn from `TextBox.DrawToBitmap` now matches in both modes. Please launch the client, toggle `Alt+Enter`, and open any dialog that hosts a `MirTextBox` (guild, chat, login, etc.) to confirm the masks now render correctly while the text boxes remain fully interactive in both windowed and fullscreen modes.
|
Your screenshot just shows a blank textbox, does it actually perform correctly with the same text box display and carat etc? |
Avoided the windowed-mode MirTextBox crash introduced after [Crystal#1142](Suprcode#1142) by only keeping the hidden WinForms `TextBox` wired into `CMain.CMain_MouseMove` while it’s actually on-screen. When the control is pushed off to `HiddenTextBoxLocation` (windowed mode), the handler is detached, so our synthetic `SendMessage` calls no longer re-enter the Mir mouse pipeline and freeze the client; the handler is re-attached automatically when fullscreen brings the textbox back.
|
Screenshot 1 = Full Screen, no text box overlay issues. I did find that the client would freeze, then close. I have done further testing and no longer freezes/client closing. I would like someone else to apply this and test for confirmation. |
|
Your screenshot doesn't show any text in the text boxes, or active carats. Show screenshots of the textbox in edit mode with a full page of text, and another of the chat bar with actife carat |
|
Crystal/Client/MirNetwork/Network.cs Line 41 in 627e11f I noticed another issue with textbox: in some scenarios client tries to update gui from network thread, which is not a good idea, and runtime will raise an exception by default. ref: https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/how-to-make-thread-safe-calls |


UpdateTextBoxHostLocationnow centralizes where the WinForms input control lives. In fullscreen it sits where it always was; in windowed mode it’s moved toHiddenTextBoxLocationso it never paints over Mir UIs.OnMouseDown/Move/Up/DoubleClick/Wheel) detect when the control is hidden and replay the corresponding Windows messages viaSendMessage, usingCMain.MPointto compute the caret position. Keyboard input still flows through the realTextBox, so all selection/editing behavior is preserved without rewriting it manually.TextBox.DrawToBitmapnow matches in both modes.@Suprcode not sure whether this is the correct direction which AI provided.