src/tracks/labeltrack/ui/LabelTrackView.cpp
// Check for keys that we will process
Check for keys that we will process
Check for keys that we will process
bool LabelTrackView::DoCaptureKey(
   AudacityProject &project, wxKeyEvent & event )
{
   int mods = event.GetModifiers();
   if (mods != wxMOD_NONE && mods != wxMOD_SHIFT) {
      return false;
   }
   auto code = event.GetKeyCode();
   const auto pTrack = FindLabelTrack();
   const auto &mLabels = pTrack->GetLabels();
   if ((code == WXK_TAB || code == WXK_NUMPAD_TAB) &&
       !mLabels.empty())
      return true;
   if (IsValidIndex(mTextEditIndex, project) || IsValidIndex(mNavigationIndex, project)) {
      if (IsGoodLabelEditKey(event)) {
         return true;
      }
   }
   else {
      bool typeToCreateLabel;
      gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, false);
      if (IsGoodLabelFirstKey(event) && typeToCreateLabel) {
#if 0
         auto gAudioIO = AudioIOBase::Get();
         if (pProj->GetAudioIOToken() > 0 &&
               gAudioIO->IsStreamActive(pProj->GetAudioIOToken()))
         {
            double t0, t1;
            pProj->GetPlayRegion(&t0, &t1);
            if (pProj->mViewInfo.selectedRegion.t0() == t0 &&
                pProj->mViewInfo.selectedRegion.t1() == t1) {
               return false;
            }
         }
#endif
         auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
         if( GetLabelIndex(selectedRegion.t0(),
                           selectedRegion.t1()) != wxNOT_FOUND ) {
            return false;
         }
         return true;
      }
   }
   return false;
}
bool LabelTrackView :: DoCaptureKey ( AudacityProject & project , wxKeyEvent & event ) { int mods = event . GetModifiers ( ) ; if ( mods != wxMOD_NONE && mods != wxMOD_SHIFT ) { return false ; } auto code = event . GetKeyCode ( ) ; const auto pTrack = FindLabelTrack ( ) ; const auto & mLabels = pTrack -> GetLabels ( ) ; if ( ( code == WXK_TAB || code == WXK_NUMPAD_TAB ) && ! mLabels . empty ( ) ) return true ; if ( IsValidIndex ( mTextEditIndex , project ) || IsValidIndex ( mNavigationIndex , project ) ) { if ( IsGoodLabelEditKey ( event ) ) { return true ; } } else { bool typeToCreateLabel ; gPrefs -> Read ( wxT ( " " ) , & typeToCreateLabel , false ) ; if ( IsGoodLabelFirstKey ( event ) && typeToCreateLabel ) { #if 0 auto gAudioIO = AudioIOBase :: Get ( ) ; if ( pProj -> GetAudioIOToken ( ) > 0 && gAudioIO -> IsStreamActive ( pProj -> GetAudioIOToken ( ) ) ) { double t0 , t1 ; pProj -> GetPlayRegion ( & t0 , & t1 ) ; if ( pProj -> mViewInfo . selectedRegion . t0 ( ) == t0 && pProj -> mViewInfo . selectedRegion . t1 ( ) == t1 ) { return false ; } } #endif auto & selectedRegion = ViewInfo :: Get ( project ) . selectedRegion ; if ( GetLabelIndex ( selectedRegion . t0 ( ) , selectedRegion . t1 ( ) ) != wxNOT_FOUND ) { return false ; } return true ; } } return false ; }
Check for keys that we will process
Check for keys that we will process
// Check for modifiers and only allow shift // Always capture the navigation keys, if we have any labels // The commented out code can prevent label creation, causing bug 1551 // We should only be in DoCaptureKey IF this label track has focus, // and in that case creating a Label is the expected/intended thing. // If we're playing, don't capture if the selection is the same as the // playback region (this helps prevent label track creation from // stealing unmodified kbd. shortcuts) // If there's a label there already don't capture