Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Jul 26, 2024
1 parent 03e9370 commit a623a72
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ internal sealed partial class PopupWindow : Window

private int _listViewItemIndex; // 0

private int _listViewItemIndexAfterContextMenuIsClosed; // 0

private int _firstVisibleListViewItemIndex; // 0

private int _currentCharPosition;
Expand Down Expand Up @@ -1080,8 +1082,15 @@ private int GetFirstVisibleListViewItemIndex()

private void ListViewItem_MouseEnter(object sender, MouseEventArgs e)
{
_listViewItemIndex = GetIndexOfListViewItemFromStackPanel((StackPanel)sender);
LastSelectedText = LastLookupResults[_listViewItemIndex].PrimarySpelling;
if (PopupContextMenu.IsVisible)
{
_listViewItemIndexAfterContextMenuIsClosed = GetIndexOfListViewItemFromStackPanel((StackPanel)sender);
}
else
{
_listViewItemIndex = GetIndexOfListViewItemFromStackPanel((StackPanel)sender);
LastSelectedText = LastLookupResults[_listViewItemIndex].PrimarySpelling;
}
}

private static void Unselect(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -1893,12 +1902,18 @@ private static bool NoAllDictFilter(object item)

private void PopupContextMenu_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (!(bool)e.NewValue
&& !IsMouseOver
&& !AddWordWindow.IsItVisible()
&& !AddNameWindow.IsItVisible())
bool contextMenuBecameInvisible = !(bool)e.NewValue;
if (contextMenuBecameInvisible)
{
PopupAutoHideTimer.Start();
_listViewItemIndex = _listViewItemIndexAfterContextMenuIsClosed;
LastSelectedText = LastLookupResults[_listViewItemIndex].PrimarySpelling;

if (!IsMouseOver
&& !AddWordWindow.IsItVisible()
&& !AddNameWindow.IsItVisible())
{
PopupAutoHideTimer.Start();
}
}
}

Expand Down

0 comments on commit a623a72

Please sign in to comment.