- // the current item must have been set before
- wxCHECK_RET( m_current != -1, _T("where is current item?") );
+ // ensure that we have a current item - we might not have it if we're
+ // given the focus with Alt or F10 press (and under GTK+ the menubar
+ // somehow gets the keyboard events even when it doesn't have focus...)
+ if ( m_current == -1 )
+ {
+ if ( !HasCapture() )
+ {
+ SelectMenu(0);
+ }
+ else // we do have capture
+ {
+ // we always maintain a valid current item while we're in modal
+ // state (i.e. have the capture)
+ wxFAIL_MSG( _T("how did we manage to lose current item?") );
+
+ return;
+ }
+ }