提交 b8bd95fc 编写于 作者: D David Poeschl 提交者: GitHub

Merge pull request #16381 from dpoeschl/NarratorAnnounceInlineRename

Have Narrator announce that an Inline Rename session has started
......@@ -108,6 +108,7 @@
<Compile Include="FindUsages\IFindUsagesContext.cs" />
<Compile Include="FindUsages\IFindUsagesService.cs" />
<Compile Include="FindUsages\SimpleFindUsagesContext.cs" />
<Compile Include="Implementation\InlineRename\Dashboard\DashboardAutomationPeer.cs" />
<Compile Include="Implementation\Structure\BlockTagState.cs" />
<Compile Include="Tags\ExportImageMonikerServiceAttribute.cs" />
<Compile Include="Implementation\NavigateTo\AbstractNavigateToItemDisplay.cs" />
......
......@@ -188,6 +188,15 @@ internal class EditorFeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to An inline rename session is active.
/// </summary>
internal static string An_inline_rename_session_is_active {
get {
return ResourceManager.GetString("An_inline_rename_session_is_active", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Apply.
/// </summary>
......
......@@ -754,4 +754,8 @@ Do you want to proceed?</value>
<data name="_0_declarations" xml:space="preserve">
<value>'{0}' declarations</value>
</data>
<data name="An_inline_rename_session_is_active" xml:space="preserve">
<value>An inline rename session is active</value>
<comment>For screenreaders</comment>
</data>
</root>
\ No newline at end of file
......@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.VisualStudio.Text.Editor;
......@@ -62,11 +63,27 @@ internal partial class Dashboard : UserControl, IDisposable
// Find UI doesn't exist in ETA.
}
// Once the Dashboard is loaded, the visual tree is completely created and the
// UIAutomation system has discovered and connected the AutomationPeer to the tree,
// allowing us to raise the AutomationFocusChanged event and have it process correctly.
// for us to set up the AutomationPeer
this.Loaded += Dashboard_Loaded;
this.Focus();
textView.Caret.IsHidden = false;
ShouldReceiveKeyboardNavigation = false;
}
private void Dashboard_Loaded(object sender, RoutedEventArgs e)
{
// Move automation focus to the Dashboard so that screenreaders will announce that the
// session has begun.
if (AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged))
{
UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
}
}
private void ShowCaret()
{
// We actually want the caret visible even though the view isn't explicitly focused.
......@@ -178,6 +195,11 @@ protected override void OnAccessKey(AccessKeyEventArgs e)
}
}
protected override AutomationPeer OnCreateAutomationPeer()
{
return new DashboardAutomationPeer(this);
}
private void DisconnectFromPresentationSource()
{
if (_rootInputElement != null)
......@@ -272,6 +294,8 @@ public void Dispose()
((UIElement)_findAdornmentLayer).LayoutUpdated -= FindAdornmentCanvas_LayoutUpdated;
}
this.Loaded -= Dashboard_Loaded;
_model.Dispose();
PresentationSource.RemoveSourceChangedHandler(this, OnPresentationSourceChanged);
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Windows.Automation.Peers;
using System.Windows.Controls;
namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
{
/// <summary>
/// Custom AutomationPeer to announce that an Inline Rename session has begun.
/// </summary>
internal class DashboardAutomationPeer : UserControlAutomationPeer
{
public DashboardAutomationPeer(UserControl owner) : base(owner)
{
}
protected override bool HasKeyboardFocusCore()
{
return true;
}
protected override bool IsKeyboardFocusableCore()
{
return true;
}
protected override string GetNameCore()
{
return EditorFeaturesResources.An_inline_rename_session_is_active;
}
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Edit;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册