Skip to content

Commit 9bd76c9

Browse files
authored
Add UIA_AutomationFocusChangedEventId to SelectInternal of the TextBoxBase.cs (#12479)
* Add UIA_AutomationFocusChangedEventId in SelectInternal function of PropertyGridView.GridViewTextBox * Add a check that when the selected text is (0, 0), let the AI ​​rectangle refocus the current text box * Rename the variables of function SelectInternal
1 parent 0ab83bf commit 9bd76c9

File tree

1 file changed

+8
-6
lines changed
  • src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox

1 file changed

+8
-6
lines changed

src/System.Windows.Forms/src/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,26 +1722,28 @@ public void Select(int start, int length)
17221722
/// But if you do have it cached, please pass it in. This will avoid
17231723
/// the expensive call to the TextLength property.
17241724
/// </summary>
1725-
private protected virtual void SelectInternal(int start, int length, int textLen)
1725+
private protected virtual void SelectInternal(int selectionStart, int selectionLength, int textLength)
17261726
{
17271727
// if our handle is created - send message...
17281728
if (IsHandleCreated)
17291729
{
1730-
AdjustSelectionStartAndEnd(start, length, out int s, out int e, textLen);
1730+
AdjustSelectionStartAndEnd(selectionStart, selectionLength, out int start, out int end, textLength);
17311731

1732-
PInvokeCore.SendMessage(this, PInvokeCore.EM_SETSEL, (WPARAM)s, (LPARAM)e);
1732+
PInvokeCore.SendMessage(this, PInvokeCore.EM_SETSEL, (WPARAM)start, (LPARAM)end);
17331733

17341734
if (IsAccessibilityObjectCreated)
17351735
{
1736-
AccessibilityObject.RaiseAutomationEvent(UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId);
1736+
AccessibilityObject.RaiseAutomationEvent(end == 0
1737+
? UIA_EVENT_ID.UIA_AutomationFocusChangedEventId
1738+
: UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId);
17371739
}
17381740
}
17391741
else
17401742
{
17411743
// otherwise, wait until handle is created to send this message.
17421744
// Store the indices until then...
1743-
_selectionStart = start;
1744-
_selectionLength = length;
1745+
_selectionStart = selectionStart;
1746+
_selectionLength = selectionLength;
17451747
_textBoxFlags[s_setSelectionOnHandleCreated] = true;
17461748
}
17471749
}

0 commit comments

Comments
 (0)