mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
[Pt Run] Narrator support for result view navigation (#6146)
* Screen reader detecting List view * Fixed narrator text for listview items and context menu items * Renamed custom textbox to a more meanigful name * Renamed custom textbox to a more meanigful name * Fix formatting of LauncherControl.xaml * Added support to control multiple elements
This commit is contained in:
parent
fc34c05a2f
commit
742f4fe36d
42
src/modules/launcher/PowerLauncher/CustomSearchBox.cs
Normal file
42
src/modules/launcher/PowerLauncher/CustomSearchBox.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
public class CustomSearchBox : TextBox
|
||||
{
|
||||
public List<UIElement> ControlledElements { get; } = new List<UIElement>();
|
||||
|
||||
protected override AutomationPeer OnCreateAutomationPeer()
|
||||
{
|
||||
return new AutoSuggestTextBoxAutomationPeer(this);
|
||||
}
|
||||
|
||||
internal class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer
|
||||
{
|
||||
public AutoSuggestTextBoxAutomationPeer(CustomSearchBox owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<AutomationPeer> GetControlledPeersCore()
|
||||
{
|
||||
var controlledPeers = new List<AutomationPeer>();
|
||||
foreach (UIElement controlledElement in ((CustomSearchBox)Owner).ControlledElements)
|
||||
{
|
||||
controlledPeers.Add(UIElementAutomationPeer.CreatePeerForElement(controlledElement));
|
||||
}
|
||||
|
||||
return controlledPeers;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PowerLauncher"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="720">
|
||||
@ -86,7 +87,7 @@
|
||||
for adding on placeholder, look at the style with 90 votes
|
||||
https://stackoverflow.com/questions/11873378/adding-placeholder-text-to-textbox
|
||||
-->
|
||||
<TextBox
|
||||
<local:CustomSearchBox
|
||||
AutomationProperties.Name="{DynamicResource Query}"
|
||||
x:Name="QueryTextBox"
|
||||
x:FieldModifier="public"
|
||||
|
@ -6,6 +6,7 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.PowerLauncher.Telemetry;
|
||||
@ -89,6 +90,7 @@ namespace PowerLauncher
|
||||
InputLanguageManager.Current.InputLanguageChanged += SearchBox_InputLanguageChanged;
|
||||
|
||||
SearchBox.QueryTextBox.Focus();
|
||||
SearchBox.QueryTextBox.ControlledElements.Add(ListBox.SuggestionsList);
|
||||
|
||||
ListBox.DataContext = _viewModel;
|
||||
ListBox.SuggestionsList.SelectionChanged += SuggestionsList_SelectionChanged;
|
||||
@ -287,7 +289,7 @@ namespace PowerLauncher
|
||||
|
||||
private void UpdateTextBoxToSelectedItem()
|
||||
{
|
||||
var itemText = _viewModel?.Results?.SelectedItem?.ToString() ?? null;
|
||||
var itemText = _viewModel?.Results?.SelectedItem?.SearchBoxDisplayText() ?? null;
|
||||
if (!string.IsNullOrEmpty(itemText))
|
||||
{
|
||||
_viewModel.ChangeQueryText(itemText);
|
||||
@ -309,7 +311,7 @@ namespace PowerLauncher
|
||||
{
|
||||
SearchBox.AutoCompleteTextBlock.Text = MainViewModel.GetAutoCompleteText(
|
||||
_viewModel.Results.SelectedIndex,
|
||||
_viewModel.Results.SelectedItem?.ToString(),
|
||||
_viewModel.Results.SelectedItem?.SearchBoxDisplayText(),
|
||||
_viewModel.QueryText);
|
||||
}
|
||||
}
|
||||
|
@ -55,5 +55,10 @@ namespace PowerLauncher.ViewModel
|
||||
};
|
||||
PowerToysTelemetry.Log.WriteEvent(eventData);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,10 +270,15 @@ namespace PowerLauncher.ViewModel
|
||||
return Result.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
public string SearchBoxDisplayText()
|
||||
{
|
||||
var display = string.IsNullOrEmpty(Result.QueryTextDisplay) ? Result.Title : Result.QueryTextDisplay;
|
||||
return display;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ namespace Wox.Plugin
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Title + SubTitle;
|
||||
return string.Format("{0} : {1}", Title, SubTitle);
|
||||
}
|
||||
|
||||
public Result()
|
||||
|
Loading…
Reference in New Issue
Block a user