diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 291b02aec..012c2e6c9 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -380,7 +380,7 @@ bool LabelDialog::TransferDataFromWindow() return false; // Add the label to it - static_cast(t)->AddLabel(rd.selectedRegion, rd.title); + static_cast(t)->AddLabel(rd.selectedRegion, rd.title,-2); static_cast(t)->Unselect(); } @@ -682,7 +682,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event)) for (i = 0; i < cnt; i++) { RowData &rd = mData[i]; - lt->AddLabel(rd.selectedRegion, rd.title); + lt->AddLabel(rd.selectedRegion, rd.title,-2); } // Export them and clean diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index f256c538b..2783315fb 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -2706,6 +2706,10 @@ int LabelTrack::GetLabelIndex(double t, double t1) return wxNOT_FOUND; } + +// restoreFocus of -1 is the default, and sets the focus to this label. +// restoreFocus of -2 or other value leaves the focus unchanged. +// restoreFocus >= 0 will later cause focus to move to that track. int LabelTrack::AddLabel(const SelectedRegion &selectedRegion, const wxString &title, int restoreFocus) { @@ -2720,7 +2724,8 @@ int LabelTrack::AddLabel(const SelectedRegion &selectedRegion, mLabels.insert(mLabels.begin() + pos, l); - mSelIndex = pos; + if( restoreFocus == -1 ) + mSelIndex = pos; // Make sure the caret is visible // diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index 640a44efd..a52cd0a73 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -217,7 +217,8 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, if (stoprun >= mStop) { lt->AddLabel(SelectedRegion(startTime, wt->LongSamplesToTime(start + s - mStop)), - wxString::Format(wxT("%lld of %lld"), startrun.as_long_long(), (samps - mStop).as_long_long())); + wxString::Format(wxT("%lld of %lld"), startrun.as_long_long(), (samps - mStop).as_long_long()), + -2); startrun = 0; stoprun = 0; samps = 0; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index cdb4dc765..ca310c05b 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -1263,7 +1263,7 @@ bool NyquistEffect::ProcessOne() // let Nyquist analyzers define more complicated selections nyx_get_label(l, &t0, &t1, &str); - ltrack->AddLabel(SelectedRegion(t0 + mT0, t1 + mT0), UTF8CTOWX(str)); + ltrack->AddLabel(SelectedRegion(t0 + mT0, t1 + mT0), UTF8CTOWX(str), -2); } return (GetType() != EffectTypeProcess || mIsPrompt); } diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 5fe06a0da..996ee9ea1 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -767,7 +767,7 @@ void VampEffect::AddFeatures(LabelTrack *ltrack, } } - ltrack->AddLabel(SelectedRegion(ltime0, ltime1), label); + ltrack->AddLabel(SelectedRegion(ltime0, ltime1), label, -2); } }