Skip to content

Commit

Permalink
TrackWindow: Fix ComboBox stealing Focus
Browse files Browse the repository at this point in the history
  • Loading branch information
mat1jaczyyy committed Oct 17, 2019
1 parent f7678d0 commit 04e242b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Apollo/Windows/TrackWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Platform;
Expand Down Expand Up @@ -211,7 +212,10 @@ void Window_KeyDown(object sender, KeyEventArgs e) {
this.Focus();
}

void Window_Focus(object sender, PointerPressedEventArgs e) => this.Focus();
void Window_LostFocus(object sender, RoutedEventArgs e) {
if (FocusManager.Instance.Current?.GetType() == typeof(ComboBox))
this.Focus();
}

void MoveWindow(object sender, PointerPressedEventArgs e) {
if (e.ClickCount == 2) Expand(e);
Expand All @@ -222,6 +226,8 @@ void MoveWindow(object sender, PointerPressedEventArgs e) {
Activate();
}

void Window_Focus(object sender, PointerPressedEventArgs e) => this.Focus();

void Minimize() => WindowState = WindowState.Minimized;

void Expand(PointerEventArgs e) {
Expand Down
2 changes: 1 addition & 1 deletion Apollo/Windows/TrackWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Width="600" MinWidth="400"
Height="274" MinHeight="274" MaxHeight="274"
Opened="Loaded" Closing="Unloaded"
KeyDown="Window_KeyDown" PointerPressed="Window_Focus">
KeyDown="Window_KeyDown" PointerPressed="Window_Focus" LostFocus="Window_LostFocus">

<Grid>
<Grid RowDefinitions="Auto,*">
Expand Down

0 comments on commit 04e242b

Please sign in to comment.