mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-06 12:42:02 +12:00
Avoid weird list view selection change due to the created native context menu.
This commit is contained in:
parent
f8f2338b73
commit
33e1d9decf
1 changed files with 21 additions and 3 deletions
|
@ -40,6 +40,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
#if TODO // SEARCH
|
#if TODO // SEARCH
|
||||||
public const string RowFilterShowAll = "[SortIndex] LIKE '%0%'";
|
public const string RowFilterShowAll = "[SortIndex] LIKE '%0%'";
|
||||||
#endif
|
#endif
|
||||||
|
private bool isShellContextMenuOpen;
|
||||||
private bool directionToRight;
|
private bool directionToRight;
|
||||||
private Point lastLocation;
|
private Point lastLocation;
|
||||||
|
|
||||||
|
@ -1186,10 +1187,21 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListViewItem_MouseEnter(object sender, MouseEventArgs e) =>
|
private void ListViewItem_MouseEnter(object sender, MouseEventArgs e)
|
||||||
CellMouseEnter?.Invoke((RowData)((ListViewItem)sender).Content);
|
{
|
||||||
|
if (!isShellContextMenuOpen)
|
||||||
|
{
|
||||||
|
CellMouseEnter?.Invoke((RowData)((ListViewItem)sender).Content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ListViewItem_MouseLeave(object sender, MouseEventArgs e) => CellMouseLeave?.Invoke();
|
private void ListViewItem_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (!isShellContextMenuOpen)
|
||||||
|
{
|
||||||
|
CellMouseLeave?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ListViewItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -1199,9 +1211,15 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
if (e.RightButton == MouseButtonState.Pressed)
|
if (e.RightButton == MouseButtonState.Pressed)
|
||||||
{
|
{
|
||||||
|
// Somehow when the TrackPopupMenuEx is called to spawn the context menu
|
||||||
|
// This will fire a MouseEnter event on the next item, like WTF?!
|
||||||
|
// Prevent any use of MouseEnter/MouseLeave while the menu is open.
|
||||||
|
// TODO: Find root case and fix this properly.
|
||||||
|
isShellContextMenuOpen = true;
|
||||||
var position = Mouse.GetPosition(this);
|
var position = Mouse.GetPosition(this);
|
||||||
position.Offset(Left, Top);
|
position.Offset(Left, Top);
|
||||||
itemData.OpenShellContextMenu(position);
|
itemData.OpenShellContextMenu(position);
|
||||||
|
isShellContextMenuOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue