Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A PowerPlant fix



For those still struggling with PowerPlant & carbon applications, here is another fix I did to LCarbonApp.

When you start your application, the usual step is to do a ObeyCommand(cmd_New, NULL) to create a new window. If your window has menus that are enabled only when the window is the target, you'll notice this weird behavior where your menu is disabled even though the window is frontmost.

This is because LCarbonApp does this in the Run() method:

..
Initialize();
ForceTargetSwitch(this);
..

The effect of this code is to reset the target and gather the enabled/disabled state of menus with the WRONG target. The fix I did is:

...
Initialize();
if (GetTarget() == NULL)
ForceTargetSwitch(this);
...

Here, the app becomes the target only if there is no other target currently set. This way, if you manually open a window just during the Initialize() method overriden by your application, you're safe with your window's specific menus.

Florent.

--
Florent Pillet, Code Segment email@hidden
Developer tools and end-user products ICQ: 117292463
Palm, Mac, Unix, Windows http://perso.wanadoo.fr/fpillet
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.