mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Settings]Colorpicker settings page focus a11y fixes (#32582)
* fixed dialog tab navigation * fixed color formats list focus
This commit is contained in:
committed by
GitHub
parent
5c352a3bf3
commit
cc4bd4486c
@@ -1,4 +1,4 @@
|
|||||||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
|
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
|
||||||
<!-- Licensed under the MIT License. See LICENSE in the project root for license information. -->
|
<!-- Licensed under the MIT License. See LICENSE in the project root for license information. -->
|
||||||
|
|
||||||
<UserControl
|
<UserControl
|
||||||
@@ -96,6 +96,7 @@
|
|||||||
|
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
x:Name="ParametersItemsControl"
|
x:Name="ParametersItemsControl"
|
||||||
|
IsTabStop="False"
|
||||||
ItemTemplate="{StaticResource FormatParameterTemplate}"
|
ItemTemplate="{StaticResource FormatParameterTemplate}"
|
||||||
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@
|
|||||||
|
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
x:Name="ColorParametersItemsControl"
|
x:Name="ColorParametersItemsControl"
|
||||||
|
IsTabStop="False"
|
||||||
ItemTemplate="{StaticResource ColorParameterTemplate}"
|
ItemTemplate="{StaticResource ColorParameterTemplate}"
|
||||||
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@
|
|||||||
<!-- Disabled reordering by dragging -->
|
<!-- Disabled reordering by dragging -->
|
||||||
<!-- CanReorderItems="True" AllowDrop="True" -->
|
<!-- CanReorderItems="True" AllowDrop="True" -->
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
|
x:Name="ColorFormats"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
AutomationProperties.Name="{Binding ElementName=ColorFormatsSetting, Path=Header}"
|
AutomationProperties.Name="{Binding ElementName=ColorFormatsSetting, Path=Header}"
|
||||||
IsTabStop="False"
|
IsTabStop="False"
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
var index = ViewModel.ColorFormats.IndexOf(color);
|
var index = ViewModel.ColorFormats.IndexOf(color);
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
ViewModel.ColorFormats.Move(index, index - 1);
|
ViewModel.ColorFormats.Move(index, --index);
|
||||||
|
SetColorFormatsFocus(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +79,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
var index = ViewModel.ColorFormats.IndexOf(color);
|
var index = ViewModel.ColorFormats.IndexOf(color);
|
||||||
if (index < ViewModel.ColorFormats.Count - 1)
|
if (index < ViewModel.ColorFormats.Count - 1)
|
||||||
{
|
{
|
||||||
ViewModel.ColorFormats.Move(index, index + 1);
|
ViewModel.ColorFormats.Move(index, ++index);
|
||||||
|
SetColorFormatsFocus(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +97,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
dialog.Content = new TextBlock() { Text = resourceLoader.GetString("Delete_Dialog_Description") };
|
dialog.Content = new TextBlock() { Text = resourceLoader.GetString("Delete_Dialog_Description") };
|
||||||
dialog.PrimaryButtonClick += (s, args) =>
|
dialog.PrimaryButtonClick += (s, args) =>
|
||||||
{
|
{
|
||||||
ViewModel.DeleteModel(color);
|
var deleteIndex = ViewModel.DeleteModel(color);
|
||||||
|
SetColorFormatsFocus(deleteIndex < ViewModel.ColorFormats.Count ? deleteIndex : ViewModel.ColorFormats.Count - 1);
|
||||||
};
|
};
|
||||||
var result = await dialog.ShowAsync();
|
var result = await dialog.ShowAsync();
|
||||||
}
|
}
|
||||||
@@ -105,6 +108,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
ColorFormatModel newColorFormat = ColorFormatDialog.DataContext as ColorFormatModel;
|
ColorFormatModel newColorFormat = ColorFormatDialog.DataContext as ColorFormatModel;
|
||||||
ViewModel.AddNewColorFormat(newColorFormat.Name, newColorFormat.Format, true);
|
ViewModel.AddNewColorFormat(newColorFormat.Name, newColorFormat.Format, true);
|
||||||
ColorFormatDialog.Hide();
|
ColorFormatDialog.Hide();
|
||||||
|
SetColorFormatsFocus(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -159,5 +163,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
modifiedColorFormat.Format = oldProperties.Value;
|
modifiedColorFormat.Format = oldProperties.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetColorFormatsFocus(int index)
|
||||||
|
{
|
||||||
|
ColorFormats.UpdateLayout();
|
||||||
|
var colorFormat = ColorFormats.ContainerFromIndex(index) as ContentPresenter;
|
||||||
|
colorFormat.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,10 +424,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
return colorFormatModel.IsValid;
|
return colorFormatModel.IsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DeleteModel(ColorFormatModel colorFormatModel)
|
internal int DeleteModel(ColorFormatModel colorFormatModel)
|
||||||
{
|
{
|
||||||
|
var deleteIndex = ColorFormats.IndexOf(colorFormatModel);
|
||||||
ColorFormats.Remove(colorFormatModel);
|
ColorFormats.Remove(colorFormatModel);
|
||||||
SetPreviewSelectedIndex();
|
return deleteIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateColorFormat(string oldName, ColorFormatModel colorFormat)
|
internal void UpdateColorFormat(string oldName, ColorFormatModel colorFormat)
|
||||||
|
|||||||
Reference in New Issue
Block a user