From 2be041868b3380cf69fa86ca86aa48d4d71a4c7a Mon Sep 17 00:00:00 2001 From: Vladimir Krestov Date: Tue, 22 Sep 2020 00:37:00 +0300 Subject: [PATCH] Fixing the incorrect ScreenReader blue rectangle for a new character when typing (Text pattern area) Fixes #3897 --- .../src/System/Windows/Forms/RichTextBox.cs | 5 +++++ .../src/System/Windows/Forms/TextBoxBase.cs | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs index 7ba1bb29759..1be3d2b5555 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs @@ -578,6 +578,11 @@ private bool ProtectedError set { richTextBoxFlags[protectedErrorSection] = value ? 1 : 0; } } + private protected override void RaiseAccessibilityTextChangedEvent() + { + // Do not do anything because Win32 provides unmanaged Text pattern for RichTextBox + } + /// /// Returns the name of the action that will be performed if the user /// Redo's their last Undone operation. If no operation can be redone, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs index 0fdddba4e5e..14510d95cb5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -1608,8 +1608,16 @@ protected override void OnTextChanged(EventArgs e) // the text changes. CommonProperties.xClearPreferredSizeCache(this); base.OnTextChanged(e); + + if (UiaCore.UiaClientsAreListening().IsTrue()) + { + RaiseAccessibilityTextChangedEvent(); + } } + private protected virtual void RaiseAccessibilityTextChangedEvent() + => AccessibilityObject.RaiseAutomationEvent(UiaCore.UIA.Text_TextChangedEventId); + /// /// Returns the character nearest to the given point. ///