• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Could kEventAppSystemUIModeChanged arrive too early to my handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Could kEventAppSystemUIModeChanged arrive too early to my handler


  • Subject: Re: Could kEventAppSystemUIModeChanged arrive too early to my handler
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 15 Jun 2008 20:10:18 +0200


Le 15 juin 08 à 18:15, Mohsan Khan a écrit :

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?

The documentation is clear about this:

GetSystemUIMode:
....
Discussion:
This function returns information about the presentation mode of the calling application, not the presentation mode of the current login session.The login session mode may be different, since the login session mode is determined by the presentation mode of the frontmost application. If the calling application is not currently the frontmost application, then its presentation mode will not be in use. To track changes in the login session’s presentation mode, you may handle the kEventAppSystemUIModeChanged Carbon event.
Yo have to query the new mode directly into the event parameters (this is an UInt32 as returned by GetSystemUIMode()):


GetEventParameter(theEvent, kEventParamSystemUIMode, typeUInt32, …);



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.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Could kEventAppSystemUIModeChanged arrive too early to my handler (From: Mohsan Khan <email@hidden>)

  • Prev by Date: Re: Static Functions and Variables
  • Next by Date: Re: Automatically Call a Function
  • Previous by thread: Could kEventAppSystemUIModeChanged arrive too early to my handler
  • Next by thread: Automatically Call a Function
  • Index(es):
    • Date
    • Thread