mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
## Summary of the Pull Request Click event on WinUI buttons handle more than just click and is more versatile that Tapped event. When you tap a Button with a finger or stylus, or press a left mouse button while the pointer is over it, the button raises the Click event. If a button has keyboard focus, pressing the Enter key or the Spacebar key also raises the Click event. This PR also replaces the right-tapped event on items on the list page with context menu handling, allowing other input gestures (such as Shift+F10) to also display the context menu. And finally, it adds a button to the status messages badge so that the flyout can be opened using the keyboard. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] **Closes:** #40616 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Tested on desktop with keyboard and mouse (no cats), and SB2 with touch and pen. Input gestures seem to work as intended. --------- Co-authored-by: Mike Griese <migrie@microsoft.com>
245 lines
12 KiB
XML
245 lines
12 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<UserControl
|
|
x:Class="Microsoft.CmdPal.UI.Controls.CommandBar"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
|
|
xmlns:cmdpalUI="using:Microsoft.CmdPal.UI"
|
|
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
|
|
xmlns:coreViewModels="using:Microsoft.CmdPal.Core.ViewModels"
|
|
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:ui="using:CommunityToolkit.WinUI"
|
|
xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels"
|
|
Background="Transparent"
|
|
mc:Ignorable="d">
|
|
|
|
<UserControl.Resources>
|
|
<ResourceDictionary>
|
|
<converters:StringVisibilityConverter
|
|
x:Key="StringNotEmptyToVisibilityConverter"
|
|
EmptyValue="Collapsed"
|
|
NotEmptyValue="Visible" />
|
|
<converters:BoolToVisibilityConverter
|
|
x:Key="BoolToInvertedVisibilityConverter"
|
|
FalseValue="Visible"
|
|
TrueValue="Collapsed" />
|
|
|
|
<cmdpalUI:MessageStateToSeverityConverter x:Key="MessageStateToSeverityConverter" />
|
|
|
|
<StackLayout
|
|
x:Name="VerticalStackLayout"
|
|
Orientation="Vertical"
|
|
Spacing="4" />
|
|
|
|
<Style
|
|
x:Name="ContextMenuFlyoutStyle"
|
|
BasedOn="{StaticResource DefaultFlyoutPresenterStyle}"
|
|
TargetType="FlyoutPresenter">
|
|
<Style.Setters>
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Padding" Value="0" />
|
|
</Style.Setters>
|
|
</Style>
|
|
|
|
<Flyout
|
|
x:Name="ContextMenuFlyout"
|
|
FlyoutPresenterStyle="{StaticResource ContextMenuFlyoutStyle}"
|
|
Opened="ContextMenuFlyout_Opened">
|
|
<cpcontrols:ContextMenu x:Name="ContextControl" />
|
|
</Flyout>
|
|
|
|
<Style x:Key="HotkeyStyle" TargetType="Border">
|
|
<Style.Setters>
|
|
<Setter Property="Padding" Value="4" />
|
|
<Setter Property="VerticalAlignment" Value="Center" />
|
|
<Setter Property="Background" Value="{ThemeResource ControlFillColorSecondaryBrush}" />
|
|
<Setter Property="BorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
<Setter Property="CornerRadius" Value="6" />
|
|
</Style.Setters>
|
|
</Style>
|
|
</ResourceDictionary>
|
|
</UserControl.Resources>
|
|
|
|
<Grid
|
|
MinHeight="40"
|
|
Padding="4"
|
|
ColumnSpacing="8">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Grid
|
|
x:Name="IconRoot"
|
|
Margin="3,0,-5,0"
|
|
Visibility="{x:Bind CurrentPageViewModel.IsNested, Mode=OneWay}">
|
|
<Button
|
|
x:Name="StatusMessagesButton"
|
|
x:Uid="StatusMessagesButton"
|
|
Padding="4"
|
|
Style="{StaticResource SubtleButtonStyle}"
|
|
Visibility="{x:Bind CurrentPageViewModel.HasStatusMessage, Mode=OneWay}">
|
|
<InfoBadge Value="{x:Bind CurrentPageViewModel.StatusMessages.Count, Mode=OneWay}" />
|
|
<Button.Flyout>
|
|
<Flyout x:Name="StatusMessagesFlyout" Placement="TopEdgeAlignedLeft">
|
|
<ItemsRepeater
|
|
x:Name="MessagesDropdown"
|
|
Margin="-8"
|
|
ItemsSource="{x:Bind CurrentPageViewModel.StatusMessages, Mode=OneWay}"
|
|
Layout="{StaticResource VerticalStackLayout}">
|
|
<ItemsRepeater.ItemTemplate>
|
|
<DataTemplate x:DataType="coreViewModels:StatusMessageViewModel">
|
|
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
|
|
<InfoBar
|
|
CornerRadius="{ThemeResource ControlCornerRadius}"
|
|
IsClosable="False"
|
|
IsOpen="True"
|
|
Message="{x:Bind Message, Mode=OneWay}"
|
|
Severity="{x:Bind State, Mode=OneWay, Converter={StaticResource MessageStateToSeverityConverter}}" />
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
</ItemsRepeater.ItemTemplate>
|
|
</ItemsRepeater>
|
|
</Flyout>
|
|
</Button.Flyout>
|
|
</Button>
|
|
</Grid>
|
|
<Button
|
|
x:Name="SettingsIconButton"
|
|
x:Uid="SettingsButton"
|
|
Click="SettingsIcon_Clicked"
|
|
Style="{StaticResource SubtleButtonStyle}"
|
|
Visibility="{x:Bind CurrentPageViewModel.IsNested, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}">
|
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
<FontIcon
|
|
VerticalAlignment="Center"
|
|
FontSize="16"
|
|
Glyph="" />
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
Style="{StaticResource CaptionTextBlockStyle}"
|
|
Text="Settings" />
|
|
</StackPanel>
|
|
</Button>
|
|
<TextBlock
|
|
Grid.Column="1"
|
|
VerticalAlignment="Center"
|
|
Style="{StaticResource CaptionTextBlockStyle}"
|
|
Text="{x:Bind CurrentPageViewModel.Title, Mode=OneWay}"
|
|
TextTrimming="CharacterEllipsis"
|
|
TextWrapping="NoWrap"
|
|
Visibility="{x:Bind CurrentPageViewModel.IsNested, Mode=OneWay}" />
|
|
<StackPanel
|
|
Grid.Column="2"
|
|
Padding="0,0,4,0"
|
|
HorizontalAlignment="Right"
|
|
Orientation="Horizontal"
|
|
Spacing="4">
|
|
<Button
|
|
x:Name="PrimaryButton"
|
|
Padding="6,4,4,4"
|
|
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
|
|
AutomationProperties.Name="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}"
|
|
Background="Transparent"
|
|
Click="PrimaryButton_Clicked"
|
|
Style="{StaticResource SubtleButtonStyle}"
|
|
Visibility="{x:Bind ViewModel.HasPrimaryCommand, Mode=OneWay}">
|
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
Style="{StaticResource CaptionTextBlockStyle}"
|
|
Text="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}" />
|
|
<Border Style="{StaticResource HotkeyStyle}">
|
|
<FontIcon
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Center"
|
|
FontSize="10"
|
|
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
|
|
Glyph="" />
|
|
</Border>
|
|
</StackPanel>
|
|
</Button>
|
|
<Button
|
|
x:Name="SecondaryButton"
|
|
Padding="6,4,4,4"
|
|
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
|
|
AutomationProperties.Name="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}"
|
|
Click="SecondaryButton_Clicked"
|
|
Style="{StaticResource SubtleButtonStyle}"
|
|
Visibility="{x:Bind ViewModel.HasSecondaryCommand, Mode=OneWay}">
|
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
Style="{StaticResource CaptionTextBlockStyle}"
|
|
Text="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}" />
|
|
<StackPanel Orientation="Horizontal" Spacing="4">
|
|
<Border Padding="4,2,4,2" Style="{StaticResource HotkeyStyle}">
|
|
<TextBlock
|
|
CharacterSpacing="4"
|
|
FontSize="10"
|
|
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
|
|
Text="Ctrl" />
|
|
</Border>
|
|
<Border Style="{StaticResource HotkeyStyle}">
|
|
<FontIcon
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Center"
|
|
FontSize="10"
|
|
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
|
|
Glyph="" />
|
|
</Border>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Button>
|
|
<Button
|
|
x:Name="MoreCommandsButton"
|
|
x:Uid="MoreCommandsButton"
|
|
Padding="4"
|
|
Click="MoreCommandsButton_Clicked"
|
|
Style="{StaticResource SubtleButtonStyle}"
|
|
ToolTipService.ToolTip="Ctrl+K"
|
|
Visibility="{x:Bind ViewModel.ShouldShowContextMenu, Mode=OneWay}">
|
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
Style="{StaticResource CaptionTextBlockStyle}"
|
|
Text="More" />
|
|
<StackPanel Orientation="Horizontal" Spacing="2">
|
|
<Border
|
|
Padding="4,2,4,2"
|
|
VerticalAlignment="Center"
|
|
Background="{ThemeResource SubtleFillColorSecondaryBrush}"
|
|
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="4">
|
|
<TextBlock
|
|
CharacterSpacing="4"
|
|
FontSize="10"
|
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
|
Text="Ctrl" />
|
|
</Border>
|
|
<Border
|
|
Padding="4,2,4,2"
|
|
VerticalAlignment="Center"
|
|
Background="{ThemeResource SubtleFillColorSecondaryBrush}"
|
|
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="4">
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
FontSize="10"
|
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
|
Text="K" />
|
|
</Border>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Button>
|
|
</StackPanel>
|
|
</Grid>
|
|
</UserControl>
|