Make find-next shortcut work in find/replace

This commit is contained in:
niksedk 2023-04-10 13:14:22 +02:00
parent 93e59fce0d
commit ddbfaa569f
2 changed files with 23 additions and 2 deletions

View File

@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Forms
public sealed partial class FindDialog : PositionAndSizeForm
{
private readonly IFindAndReplace _findAndReplaceMethods;
private readonly Keys _findNextShortcut;
private Regex _regEx;
private readonly Subtitle _subtitle;
@ -40,6 +40,7 @@ namespace Nikse.SubtitleEdit.Forms
}
UiUtil.FixLargeFonts(this, buttonFind);
_findNextShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFindNext);
}
private ReplaceType FindReplaceType
@ -102,9 +103,19 @@ namespace Nikse.SubtitleEdit.Forms
{
if (e.KeyCode == Keys.Escape)
{
e.Handled = true;
DialogResult = DialogResult.Cancel;
Close();
}
else if (e.KeyData == _findNextShortcut)
{
e.Handled = true;
e.SuppressKeyPress = true;
var ctrl = ActiveControl;
FindNext();
Focus();
ctrl?.Focus();
}
}
private void ButtonFind_Click(object sender, EventArgs e)

View File

@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Forms
public sealed partial class ReplaceDialog : PositionAndSizeForm
{
private readonly IFindAndReplace _findAndReplaceMethods;
private readonly Keys _findNextShortcut;
private Regex _regEx;
private bool _userAction;
private bool _findNext;
@ -42,6 +42,7 @@ namespace Nikse.SubtitleEdit.Forms
}
UiUtil.FixLargeFonts(this, buttonReplace);
_findNextShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFindNext);
}
public bool ReplaceAll { get; set; }
@ -79,6 +80,15 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult = DialogResult.Cancel;
Close();
}
else if (e.KeyData == _findNextShortcut)
{
e.Handled = true;
e.SuppressKeyPress = true;
var ctrl = ActiveControl;
Find();
Focus();
ctrl?.Focus();
}
}
internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper)