Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / November 2005



Tip: Looking for answers? Try searching our database.

interface builder hierarchical menu handle?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wiley - 27 Nov 2005 22:27 GMT
I'm using Xcode.  I can't use CheckMenuItem in a Carbon app using nib
files.  It doesn't change the checkmark associated with an item.  This is
only true in hierarchical menus.  Checking items works fine in normal
menus.  The menu commands in the hierarchical menu work fine because their
CommandId constants link directly into my code's menu handler callback
without a need to get the MenuHandle of the hierarchical menu.  However,
in order to change the checkmark of an item in a hierarchical menu, I need
the MenuHandle or MenuRef (not clear on the difference) of the menu.  The
only information I have for the menu is the ID I entered for it into
interface builder.

I have tried the following functions:

GetMenu
GetMenuRef
GetMenuHandle
GetMenuID

The first three take numbers, the last takes a MenuRef, so clearly the
last one doesn't work if the others don't work.  I tried all of these with
the ID I entered in interface builder and they all return 0.  Back in
resource based OS 9 world, the number I would enter would be the resource
ID of the menu, and of course that worked, but using the IB menu id in
these functions doesn't work.  I guess it isn't a resource id even though
these IDs are often similar to old resource ids.

So, how do I get the MenuHandle for a hierarchical menu in a nib file?
...or to state the underlying question more directly, how do I alter the
checkmark status of items in a hierarchical menu?

Thanks.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Chris Baum - 28 Nov 2005 03:16 GMT
> I can't use CheckMenuItem in a Carbon app using nib
> files.  It doesn't change the checkmark associated with an item.  This is
[quoted text clipped - 6 lines]
> only information I have for the menu is the ID I entered for it into
> interface builder.

CheckMenuItem works fine in submenus.  Do you have a MenuRef for the
parent menu?  If so, use GetMenuItemHierarchicalMenu to get the
submenu's MenuRef, then use GetIndMenuItemWithCommandID to get the
MenuItemIndex in question.   CheckMenuItem should work fine with those
params.
Chris Baum - 28 Nov 2005 03:32 GMT
> > I can't use CheckMenuItem in a Carbon app using nib
> > files.  It doesn't change the checkmark associated with an item.  This is
[quoted text clipped - 12 lines]
> MenuItemIndex in question.   CheckMenuItem should work fine with those
> params.

It also occurs to me to ask - why do need to set the checkmark outside
of a CarbonEvent handler that isn't providing the MenuRef to you?  

Maybe a better answer is to revise your approach.   Call CheckMenuItem
in response to the kEventCommandUpdateStatus event which includes the
MenuRef and ItemIndex.
Keith Wiley - 28 Nov 2005 17:33 GMT
Thanks.  I'll try those ideas.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.