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
This commit is contained in:
Leaf Shi 2024-12-09 17:28:29 +08:00 коммит произвёл GitHub
Родитель 0ab83bffe8
Коммит 9bd76c9152
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -1722,26 +1722,28 @@ public abstract partial class TextBoxBase : Control
/// But if you do have it cached, please pass it in. This will avoid
/// the expensive call to the TextLength property.
/// </summary>
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(UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId);
AccessibilityObject.RaiseAutomationEvent(end == 0
? UIA_EVENT_ID.UIA_AutomationFocusChangedEventId
: UIA_EVENT_ID.UIA_Text_TextSelectionChangedEventId);
}
}
else
{
// 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;
}
}