Focus line after "go to line"

This commit is contained in:
niksedk 2016-01-22 20:51:17 +01:00
parent 69a6bf913c
commit 512786ecea

View File

@ -269,30 +269,21 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (e.KeyData == (Keys.Control | Keys.G)) else if (e.KeyData == (Keys.Control | Keys.G))
{ {
var isSubtitleListview1Active = true; var subView = SubtitleListview1;
if (subtitleListView2 != null && subtitleListView2.Visible) if (subtitleListView2 != null && subtitleListView2.Visible && !SubtitleListview1.Focused)
{ {
var point = PointToClient(MousePosition); var x = PointToClient(MousePosition).X;
if (point.X >= subtitleListView2.Left && point.X <= subtitleListView2.Left + subtitleListView2.Width) if (x >= subtitleListView2.Left && x <= subtitleListView2.Left + subtitleListView2.Width)
{ {
isSubtitleListview1Active = false; subView = subtitleListView2;
} }
} }
using (var gotoForm = new GoToLine()) using (var gotoForm = new GoToLine())
{ {
gotoForm.Initialize(1, isSubtitleListview1Active ? _subtitle.Paragraphs.Count : _otherSubtitle.Paragraphs.Count); gotoForm.Initialize(1, subView.Items.Count);
if (gotoForm.ShowDialog() == DialogResult.OK) if (gotoForm.ShowDialog() == DialogResult.OK)
{ {
if (isSubtitleListview1Active) subView.SelectIndexAndEnsureVisible(gotoForm.LineNumber - 1, true);
{
SubtitleListview1.Items[gotoForm.LineNumber - 1].Selected = true;
SubtitleListview1.EnsureVisible(gotoForm.LineNumber - 1);
}
else
{
subtitleListView2.Items[gotoForm.LineNumber - 1].Selected = true;
subtitleListView2.EnsureVisible(gotoForm.LineNumber - 1);
}
} }
} }
} }