Skip navigation.
 
mlCould kEventAppSystemUIModeChanged arrive too early to my handler
FROM : Mohsan Khan
DATE : Sun Jun 15 18:15:49 2008

Hi

I'm trying to handle when some other app changes to fullscreen by 
handling the kEventAppSystemUIModeChanged event.

The event handler is called but then when I check if the menu bar is 
visibe I get TRUE!

So I figured, either the apps I'm testing fullscreen mode with (VLC, 
Photoshop) don't really enter fullscreen mode as they should like Mac 
OS X wants an app too.
Or, the event arrives too early, I even tried putting a 2 seconds 
sleep but get the same result - menu is always visible.

I must be doing something wrong here, maybe there is a simpler Cocoa 
way?


pascal OSStatus AppEventHandler( EventHandlerCallRef inCallRef, 
EventRef inEvent, void* inUserData )
{
   #pragma unused( inCallRef, inUserData )
   
   //sleep( 2 );
   
   OSStatus status = eventNotHandledErr;
   
   switch( GetEventClass( inEvent ) )
   {
       case kEventClassApplication:
       {
           NSLog( @"kEventClassApplication" );
           
           // check menu visibility, or ui mode
           SystemUIMode *outMode;
           SystemUIOptions *outOptions;
           
           GetSystemUIMode( outMode, outOptions );
           
           NSLog( @"UI mode: %d %d", *outMode, *outOptions );    // = 0 0
           
           NSLog( @"menu: %d", [NSMenu menuBarVisible] );        // = 1
           NSLog( @"menu: %d", IsMenuBarVisible() );            // = 1
           
           status = noErr;        // everything went well, event handled
       }
       break;
       
       default:
       {
           NSLog( @"..." );
       }
       break;
   }
   
   
    return status;
}

static const EventTypeSpec sAppEvents[] = { { kEventClassApplication, 
kEventAppSystemUIModeChanged } };

InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler ),
                           GetEventTypeCount( sAppEvents ),
                           sAppEvents, 0, NULL );

Thanks.


Yours sincerely,
            Mohsan Khan.
_______________________________________________________________
www.xybernic.com
There is no place like 127.0.0.1.

Related mailsAuthorDate
mlCould kEventAppSystemUIModeChanged arrive too early to my handler Mohsan Khan Jun 15, 18:15
mlRe: Could kEventAppSystemUIModeChanged arrive too early to my handler Jean-Daniel Dupas Jun 15, 20:10