From 76e5ac3decdc3ffdad1e543638bc633938c1f371 Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Thu, 14 Nov 2024 15:33:28 +0800 Subject: [PATCH 1/3] Add UIA_AutomationFocusChangedEventId in SelectInternal function of PropertyGridView.GridViewTextBox --- .../PropertyGridView.GridViewTextBox.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs index 10984600a7b..7398bdd65e5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs @@ -306,6 +306,15 @@ private unsafe bool WmNotify(ref Message m) return false; } + private protected override void SelectInternal(int start, int length, int textLen) + { + base.SelectInternal(start, length, textLen); + if (IsAccessibilityObjectCreated) + { + AccessibilityObject.RaiseAutomationEvent(UIA_EVENT_ID.UIA_AutomationFocusChangedEventId); + } + } + protected override void WndProc(ref Message m) { if (_filter && PropertyGridView.FilterEditWndProc(ref m)) From 0710ba7dc0341e9eb488450ad7c559520aa17c71 Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Tue, 19 Nov 2024 09:41:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Add=20a=20check=20that=20when=20the=20selec?= =?UTF-8?q?ted=20text=20is=20(0,=200),=20let=20the=20AI=20=E2=80=8B?= =?UTF-8?q?=E2=80=8Brectangle=20refocus=20the=20current=20text=20box?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PropertyGridView.GridViewTextBox.cs | 9 --------- .../System/Windows/Forms/Controls/TextBox/TextBoxBase.cs | 4 +++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs index 7398bdd65e5..10984600a7b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs @@ -306,15 +306,6 @@ private unsafe bool WmNotify(ref Message m) return false; } - private protected override void SelectInternal(int start, int length, int textLen) - { - base.SelectInternal(start, length, textLen); - if (IsAccessibilityObjectCreated) - { - AccessibilityObject.RaiseAutomationEvent(UIA_EVENT_ID.UIA_AutomationFocusChangedEventId); - } - } - protected override void WndProc(ref Message m) { if (_filter && PropertyGridView.FilterEditWndProc(ref m)) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs index dc4ddfd02db..bdd773c1064 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs @@ -1741,7 +1741,9 @@ private protected virtual void SelectInternal(int start, int length, int textLen if (IsAccessibilityObjectCreated) { - AccessibilityObject.RaiseAutomationEvent(UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId); + AccessibilityObject.RaiseAutomationEvent(e == 0 + ? UIA_EVENT_ID.UIA_AutomationFocusChangedEventId + : UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId); } } else From 598a854f0b499a89587d4fbcdb36de1ea527126e Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Fri, 22 Nov 2024 09:54:38 +0800 Subject: [PATCH 3/3] Rename the variables of function SelectInternal --- .../Windows/Forms/Controls/TextBox/TextBoxBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs index bdd773c1064..3589cce1970 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs @@ -1730,18 +1730,18 @@ public void Select(int start, int length) /// But if you do have it cached, please pass it in. This will avoid /// the expensive call to the TextLength property. /// - private protected virtual void SelectInternal(int start, int length, int textLen) + private protected virtual void SelectInternal(int selectionStart, int selectionLength, int textLength) { // if our handle is created - send message... if (IsHandleCreated) { - AdjustSelectionStartAndEnd(start, length, out int s, out int e, textLen); + AdjustSelectionStartAndEnd(selectionStart, selectionLength, out int start, out int end, textLength); - PInvokeCore.SendMessage(this, PInvokeCore.EM_SETSEL, (WPARAM)s, (LPARAM)e); + PInvokeCore.SendMessage(this, PInvokeCore.EM_SETSEL, (WPARAM)start, (LPARAM)end); if (IsAccessibilityObjectCreated) { - AccessibilityObject.RaiseAutomationEvent(e == 0 + AccessibilityObject.RaiseAutomationEvent(end == 0 ? UIA_EVENT_ID.UIA_AutomationFocusChangedEventId : UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId); } @@ -1750,8 +1750,8 @@ private protected virtual void SelectInternal(int start, int length, int textLen { // otherwise, wait until handle is created to send this message. // Store the indices until then... - _selectionStart = start; - _selectionLength = length; + _selectionStart = selectionStart; + _selectionLength = selectionLength; _textBoxFlags[s_setSelectionOnHandleCreated] = true; } }