Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Dec 14, 2024
1 parent ad5b544 commit 021ba31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down
23 changes: 11 additions & 12 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 021ba31

Please sign in to comment.