MCPcopy Create free account
hub / github.com/LMMS/lmms / focusOutEvent

Method focusOutEvent

src/gui/PianoView.cpp:660–690  ·  view source on GitHub ↗

! \brief Handle the focus leaving the piano display view * * Turn off all notes if we lose focus. * * \todo Is there supposed to be a parameter given here? */

Source from the content-addressed store, hash-verified

658 * \todo Is there supposed to be a parameter given here?
659 */
660void PianoView::focusOutEvent( QFocusEvent * )
661{
662 if( m_piano == NULL )
663 {
664 return;
665 }
666
667 // focus just switched to another control inside the instrument track
668 // window we live in?
669 if( parentWidget()->parentWidget()->focusWidget() != this &&
670 parentWidget()->parentWidget()->focusWidget() != NULL &&
671 !(parentWidget()->parentWidget()->
672 focusWidget()->inherits( "QLineEdit" ) ||
673 parentWidget()->parentWidget()->
674 focusWidget()->inherits( "QPlainTextEdit" ) ))
675 {
676 // then reclaim keyboard focus!
677 setFocus();
678 return;
679 }
680
681 // if we loose focus, we HAVE to note off all running notes because
682 // we don't receive key-release-events anymore and so the notes would
683 // hang otherwise
684 for( int i = 0; i < NumKeys; ++i )
685 {
686 m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, -1, i, 0 ) );
687 m_piano->setKeyState( i, false );
688 }
689 update();
690}
691
692
693

Callers

nothing calls this directly

Calls 4

midiEventProcessorMethod · 0.80
setKeyStateMethod · 0.80
MidiEventClass · 0.50
processInEventMethod · 0.45

Tested by

no test coverage detected