Compare commits

..

5 Commits

Author SHA1 Message Date
Jessica Dene Earley-Cha
63c4cb5916 add checks that the keydownevent for DeleteButton_KeyDown is triggered from DeleteButton 2025-08-12 13:33:21 -07:00
Jessica Dene Earley-Cha
b0e3143682 change button to content and used Uid to have screenreader annouce button 2025-08-11 13:32:38 -07:00
Jessica Dene Earley-Cha
5a70d392a4 clear search button and enter clears search box and moves focus back to search bar 2025-08-11 11:16:10 -07:00
Jessica Dene Earley-Cha
a629a2fff3 deletebutton appears and disapears based on input text and is tabable 2025-08-07 14:31:41 -07:00
leileizhang
fed6e523b6 Fix: used wrong preview resize event from another handler (#40995)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Bug: Was using GcodePreviewResizeEvent, which will never work — switched
to use Bgcode's own event

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
- [ ] **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

## AI Summary
This pull request makes a minor update to the event handling in the
preview pane module. The change updates the event constant used for
resizing the preview from `GcodePreviewResizeEvent` to
`BgcodePreviewResizeEvent`, likely to improve naming consistency or to
support a new event type.
2025-08-06 14:12:37 +08:00
4 changed files with 55 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="RootSearchBar"
mc:Ignorable="d">
<UserControl.Resources>

View File

@@ -2,6 +2,8 @@
// 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.Windows.Input;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.CmdPal.Core.ViewModels;
@@ -36,6 +38,9 @@ public sealed partial class SearchBar : UserControl,
private string? _lastText;
private string? _deletedSuggestion;
// An ICommand for clearing the search box, allowing the DeleteButton to invoke this logic via MVVM command binding.
public ICommand ClearSearchCommand { get; }
public PageViewModel? CurrentPageViewModel
{
get => (PageViewModel?)GetValue(CurrentPageViewModelProperty);
@@ -75,6 +80,11 @@ public sealed partial class SearchBar : UserControl,
WeakReferenceMessenger.Default.Register<GoHomeMessage>(this);
WeakReferenceMessenger.Default.Register<FocusSearchBoxMessage>(this);
WeakReferenceMessenger.Default.Register<UpdateSuggestionMessage>(this);
// Attach a keydown event handler Clear Button within the FilterBox to trigger search clearing logic.
FilterBox.AddHandler(Button.KeyDownEvent, new KeyEventHandler(DeleteButton_KeyDown), true);
ClearSearchCommand = new RelayCommand(() => ExecuteDeleteButtonAction());
}
public void ClearSearch()
@@ -92,6 +102,36 @@ public sealed partial class SearchBar : UserControl,
}));
}
private Button? GetDeleteButton()
{
// Try to find the DeleteButton in the FilterBox's template
return FilterBox?.FindName("DeleteButton") as Button;
}
private bool IsDeleteButtonFocused()
{
var deleteButton = GetDeleteButton();
var focusedElement = FocusManager.GetFocusedElement() as Button;
return deleteButton != null && focusedElement == deleteButton;
}
public void DeleteButton_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (IsDeleteButtonFocused())
{
if (e.Key == VirtualKey.Enter)
{
ExecuteDeleteButtonAction();
}
}
}
private void ExecuteDeleteButtonAction()
{
ClearSearch();
FilterBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
}
public void SelectSearch()
{
// TODO GH #239 switch back when using the new MD text block

View File

@@ -434,4 +434,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<data name="StatusMessagesButton.[using:Microsoft.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Show status messages</value>
</data>
<data name="DeleteButton.AutomationProperties.Name" xml:space="preserve">
<value>Clears the search box</value>
</data>
</root>

View File

@@ -14,6 +14,11 @@
EmptyValue="Visible"
NotEmptyValue="Collapsed" />
<converters:StringVisibilityConverter
x:Key="StringVisibilityConverter"
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
<Style x:Key="SearchTextBoxStyle" TargetType="TextBox">
<Setter Property="Foreground" Value="{ThemeResource TextControlForeground}" />
<Setter Property="Background" Value="Transparent" />
@@ -166,18 +171,21 @@
Visibility="{Binding Description, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ReverseStringVisibilityConverter}, Mode=OneWay}" />
<Button
x:Name="DeleteButton"
x:Uid="DeleteButton"
Grid.Column="2"
Margin="0,0,8,0"
Padding="4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
AutomationProperties.AccessibilityView="Content"
BorderThickness="{TemplateBinding BorderThickness}"
Command="{Binding ClearSearchCommand, ElementName=RootSearchBar}"
CornerRadius="{TemplateBinding CornerRadius}"
FontSize="{TemplateBinding FontSize}"
IsTabStop="False"
IsTabStop="True"
KeyDown="DeleteButton_KeyDown"
Style="{StaticResource DeleteButtonStyle}"
Visibility="Collapsed" />
Visibility="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringVisibilityConverter}, Mode=OneWay}" />
<TextBlock
x:Name="DescriptionPresenter"
Grid.Column="1"