mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
Improve focus handling and window initialization
Added `IsTabStop="True"` to `RootGrid` in `MainWindow.xaml` to make it focusable. Updated `DispatcherQueue.TryEnqueue` in `MainWindow.xaml.cs` to clear focus from interactive elements (e.g., sliders) on window open, preventing unwanted tooltips and ensuring a cleaner initial state.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<DesktopAcrylicBackdrop />
|
||||
</winuiex:WindowEx.SystemBackdrop>
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<Grid x:Name="RootGrid" IsTabStop="True">
|
||||
<Grid.Resources>
|
||||
<Style
|
||||
x:Key="FlyoutButtonStyle"
|
||||
|
||||
@@ -219,7 +219,14 @@ namespace PowerDisplay
|
||||
// This is critical because the OS might restore the window to a previous (incorrect) size
|
||||
// when ShowWindow is called, ignoring our pre-show adjustment.
|
||||
// By queuing this on the dispatcher, we ensure it runs after the window is visible and layout is active.
|
||||
DispatcherQueue.TryEnqueue(() => AdjustWindowSizeToContent());
|
||||
DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
AdjustWindowSizeToContent();
|
||||
|
||||
// Clear focus from any interactive element (e.g., Slider) to prevent
|
||||
// showing the value tooltip when the window opens
|
||||
RootGrid.Focus(FocusState.Programmatic);
|
||||
});
|
||||
|
||||
bool isVisible = IsWindowVisible();
|
||||
if (!isVisible)
|
||||
|
||||
Reference in New Issue
Block a user