From 021ba313d6e29a535dd6dc103ea9a4df6b8e6d4b Mon Sep 17 00:00:00 2001 From: rampaa Date: Sat, 14 Dec 2024 14:56:19 +0300 Subject: [PATCH] Minor --- JL.Windows/GUI/MainWindow.xaml.cs | 4 ++-- JL.Windows/GUI/PopupWindow.xaml.cs | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index 49377842..3dbe8559 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -312,7 +312,7 @@ public Task HandleMouseMove(MouseEventArgs? e) || (!configManager.TextBoxIsReadOnly && InputMethod.Current?.ImeState is InputMethodState.On) || (configManager.RequireLookupKeyPress && !configManager.LookupKeyKeyGesture.IsPressed()) ? Task.CompletedTask - : FirstPopupWindow.LookupOnMouseMoveOrClick(MainTextBox); + : FirstPopupWindow.LookupOnMouseMoveOrClick(MainTextBox, false); } // ReSharper disable once AsyncVoidMethod @@ -1136,7 +1136,7 @@ private async void MainTextBox_PreviewMouseUp(object? sender, MouseButtonEventAr else { - await FirstPopupWindow.LookupOnMouseMoveOrClick(MainTextBox).ConfigureAwait(false); + await FirstPopupWindow.LookupOnMouseMoveOrClick(MainTextBox, true).ConfigureAwait(false); } } diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index 20387622..aa8b787c 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -306,22 +306,21 @@ public Task LookupOnCharPosition(TextBox textBox, int charPosition, bool enableM return Task.CompletedTask; } - public Task LookupOnMouseMoveOrClick(TextBox textBox) + public Task LookupOnMouseMoveOrClick(TextBox textBox, bool enableMiningMode) { int charPosition = textBox.GetCharacterIndexFromPoint(Mouse.GetPosition(textBox), false); - - if (charPosition >= 0) + if (charPosition < 0) { - if (charPosition > 0 && char.IsHighSurrogate(textBox.Text[charPosition - 1])) - { - --charPosition; - } + HidePopup(); + return Task.CompletedTask; + } - return LookupOnCharPosition(textBox, charPosition, ConfigManager.Instance.LookupOnMouseClickOnly); + if (charPosition > 0 && char.IsHighSurrogate(textBox.Text[charPosition - 1])) + { + --charPosition; } - HidePopup(); - return Task.CompletedTask; + return LookupOnCharPosition(textBox, charPosition, enableMiningMode); } public Task LookupOnSelect(TextBox textBox) @@ -1206,7 +1205,7 @@ private Task HandleTextBoxMouseMove(TextBox textBox, MouseEventArgs? e) _lastInteractedTextBox = textBox; if (JapaneseUtils.JapaneseRegex().IsMatch(textBox.Text)) { - return ChildPopupWindow.LookupOnMouseMoveOrClick(textBox); + return ChildPopupWindow.LookupOnMouseMoveOrClick(textBox, false); } if (configManager.HighlightLongestMatch) @@ -1818,7 +1817,7 @@ private async void TextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e) else { - await ChildPopupWindow.LookupOnMouseMoveOrClick((TextBox)sender).ConfigureAwait(false); + await ChildPopupWindow.LookupOnMouseMoveOrClick((TextBox)sender, true).ConfigureAwait(false); } }