Skip to content

Commit

Permalink
[FancyZones Editor][Accessibility] Default focused elements in all Fa…
Browse files Browse the repository at this point in the history
…ncyZones Editor windows (#7971)

* Default focused elements

* Fix focus when starting editor from settings
  • Loading branch information
stefansjfw committed Nov 12, 2020
1 parent 6a580c7 commit 102f429
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</Style>

</Window.Resources>
<StackPanel>
<StackPanel FocusManager.FocusedElement="{Binding ElementName=newZoneButton}">
<TextBlock Name="windowEditorDialogTitle" Text="{x:Static props:Resources.Custom_Layout_Creator}" Style="{StaticResource titleText}" />
<Button x:Name="newZoneButton" AutomationProperties.LabeledBy="{Binding ElementName=newZoneName}" Width="496" Height="136" Style="{StaticResource newZoneButton}" Click="OnAddZone">
<StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@

<TextBlock Text="{x:Static props:Resources.Note_Custom_Table}" Style="{StaticResource textLabel}" TextWrapping="Wrap" />
<TextBlock x:Name="customLayoutName" Text="{x:Static props:Resources.Name}" Style="{StaticResource textLabel}" />
<TextBox Text="{Binding Name}" AutomationProperties.LabeledBy="{Binding ElementName=customLayoutName}" Style="{StaticResource textBox}" />
<TextBox Name="customLayoutNameTextBox" Text="{Binding Name}" GotFocus="NameTextBox_GotFocus" AutomationProperties.LabeledBy="{Binding ElementName=customLayoutName}" Style="{StaticResource textBox}" />
<!--
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<CheckBox x:Name="showGridSetting" VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="True" Margin="21,4,0,0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,15 @@ private void GridEditorWindow_KeyUp(object sender, KeyEventArgs e)
}

private GridLayoutModel _stashedModel;

private void NameTextBox_GotFocus(object sender, RoutedEventArgs e)
{
customLayoutNameTextBox.CaretIndex = customLayoutNameTextBox.Text.Length;
}

public System.Windows.Controls.TextBox NameTextBox()
{
return customLayoutNameTextBox;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<StackPanel>

<StackPanel FocusManager.FocusedElement="{Binding ElementName=decrementZones}">

<TextBlock Name="DialogTitle" Text="{x:Static props:Resources.Choose_Layout}" Style="{StaticResource titleText}" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ private void EditLayout_Click(object sender, RoutedEventArgs e)
mainEditor.Edit();

EditorWindow window;
bool isGrid = false;
if (model is GridLayoutModel)
{
window = new GridEditorWindow();
isGrid = true;
}
else
{
Expand All @@ -166,6 +168,10 @@ private void EditLayout_Click(object sender, RoutedEventArgs e)
window.Owner = EditorOverlay.Current;
window.DataContext = model;
window.Show();
if (isGrid)
{
(window as GridEditorWindow).NameTextBox().Focus();
}
}

private void Apply_Click(object sender, RoutedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/fancyzones/lib/FancyZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void FancyZones::ToggleEditor() noexcept
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
sei.lpFile = NonLocalizable::FZEditorExecutablePath;
sei.lpParameters = params.c_str();
sei.nShow = SW_SHOWNORMAL;
sei.nShow = SW_SHOWDEFAULT;
ShellExecuteEx(&sei);
Trace::FancyZones::EditorLaunched(1);

Expand Down

0 comments on commit 102f429

Please sign in to comment.