Browse Source

Use focus-visible instead of custom focusvisual

pull/4209/head
Maksym Katsydan 6 years ago
parent
commit
300a6952d1
  1. 15
      src/Avalonia.Controls/ComboBox.cs
  2. 12
      src/Avalonia.Themes.Fluent/ComboBox.xaml

15
src/Avalonia.Controls/ComboBox.cs

@ -262,21 +262,6 @@ namespace Avalonia.Controls
_popup.Closed += PopupClosed;
}
protected override void OnGotFocus(GotFocusEventArgs e)
{
if (e.NavigationMethod == NavigationMethod.Tab
|| e.NavigationMethod == NavigationMethod.Directional)
{
PseudoClasses.Set(":focusvisual", true);
}
}
protected override void OnLostFocus(RoutedEventArgs e)
{
base.OnLostFocus(e);
PseudoClasses.Set(":focusvisual", false);
}
/// <summary>
/// Called when the ComboBox popup is closed, with the <see cref="PopupClosedEventArgs"/>
/// that caused the popup to close.

12
src/Avalonia.Themes.Fluent/ComboBox.xaml

@ -191,20 +191,20 @@
</Style>
<!-- Focused State -->
<Style Selector="ComboBox:focusvisual /template/ Border#HighlightBackground">
<Style Selector="ComboBox:focus-visible /template/ Border#HighlightBackground">
<Setter Property="IsVisible" Value="True" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBackgroundBorderBrushFocused}" />
</Style>
<Style Selector="ComboBox:focusvisual /template/ ContentControl#ContentPresenter">
<Style Selector="ComboBox:focus-visible /template/ ContentControl#ContentPresenter">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="ComboBox:focusvisual /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextBlock.Foreground" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={DynamicResource ComboBoxForegroundFocused}}" />
<Style Selector="ComboBox:focus-visible /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="ComboBox:focusvisual /template/ Path#DropDownGlyph">
<Style Selector="ComboBox:focus-visible /template/ Path#DropDownGlyph">
<Setter Property="Fill" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
</Style>
@ -214,7 +214,7 @@
</Style>
<Style Selector="ComboBox:focused:pressed /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextBlock.Foreground" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}}" />
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
</Style>
<Style Selector="ComboBox:focused:pressed /template/ Path#DropDownGlyph">

Loading…
Cancel
Save