fix unexpected hovor without mouse moving (#2368)

fix #975 
close #2043
This commit is contained in:
KallistiMan
2019-02-22 20:36:21 +01:00
committed by jhdxr
parent a6e82475a3
commit 1ab636a4f1
2 changed files with 28 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
using System.Runtime.Remoting.Contexts;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -7,6 +8,8 @@ namespace Wox
[Synchronization]
public partial class ResultListBox
{
private Point _lastpos;
private ListBoxItem curItem = null;
public ResultListBox()
{
InitializeComponent();
@@ -22,7 +25,26 @@ namespace Wox
private void OnMouseEnter(object sender, MouseEventArgs e)
{
((ListBoxItem) sender).IsSelected = true;
curItem = (ListBoxItem)sender;
var p = e.GetPosition((IInputElement)sender);
_lastpos = p;
}
private void OnMouseMove(object sender, MouseEventArgs e)
{
var p = e.GetPosition((IInputElement)sender);
if (_lastpos != p)
{
((ListBoxItem) sender).IsSelected = true;
}
}
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (curItem != null)
{
curItem.IsSelected = true;
}
}
}
}
}