From b00092e4a5cb788951757f61143bff05742dcddb Mon Sep 17 00:00:00 2001 From: Peter Kirmeier Date: Sun, 17 Sep 2023 19:11:08 +0200 Subject: [PATCH] Reintroduce hover state of list items Items were immediately selected when mouse hovered over --- Business/WaitToLoadMenu.cs | 7 ++++++- UserInterface/Menu.xaml | 2 +- UserInterface/Menu.xaml.cs | 19 ------------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Business/WaitToLoadMenu.cs b/Business/WaitToLoadMenu.cs index 11810bc..6d447f1 100644 --- a/Business/WaitToLoadMenu.cs +++ b/Business/WaitToLoadMenu.cs @@ -32,7 +32,6 @@ namespace SystemTrayMenu.Business { if (MouseActive) { - MouseSelect?.Invoke(itemData); timerStartLoad.Stop(); StopLoadMenu?.Invoke(); SetData(itemData); @@ -72,6 +71,7 @@ namespace SystemTrayMenu.Business StopLoadMenu?.Invoke(); SetData(itemData); MouseActive = true; + MouseSelect?.Invoke(itemData); OpenSubMenu(); } @@ -88,6 +88,11 @@ namespace SystemTrayMenu.Business { timerStartLoad.Stop(); StopLoadMenu?.Invoke(); + if (MouseActive && currentItemData != null) + { + MouseSelect?.Invoke(currentItemData); + } + OpenSubMenu(); } diff --git a/UserInterface/Menu.xaml b/UserInterface/Menu.xaml index bac93f5..8f192c2 100644 --- a/UserInterface/Menu.xaml +++ b/UserInterface/Menu.xaml @@ -176,7 +176,7 @@ diff --git a/UserInterface/Menu.xaml.cs b/UserInterface/Menu.xaml.cs index 920233c..56be8cb 100644 --- a/UserInterface/Menu.xaml.cs +++ b/UserInterface/Menu.xaml.cs @@ -1117,25 +1117,6 @@ namespace SystemTrayMenu.UserInterface } } - private void ListView_MouseLeave(object sender, MouseEventArgs e) - { - // In case a sub menu is already open and another item was already selected - // but WaitToLoadMenu hasn't take action yet - // then we want to reset that selection, so the sub menu selection remains active only - if (SubMenu != null) - { - ListView lv = (ListView)sender; - foreach (RowData itemData in lv.Items) - { - if (itemData.SubMenu == SubMenu) - { - lv.SelectedItem = itemData; - break; - } - } - } - } - private void ListView_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { int count = dgv.Items.Count;