• 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: Removing / inserting Menuitems in Mainmenu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing / inserting Menuitems in Mainmenu


  • Subject: Re: Removing / inserting Menuitems in Mainmenu
  • From: "I. Savant" <email@hidden>
  • Date: Sat, 17 Feb 2007 12:05:55 -0500

Stefan:

Menus are not normally 'added and removed'. Rather they are 'enabled and disabled'. You should simply validate the menu items (check out <NSMenuValidation> in the documentation).

--
I.S.


On Feb 17, 2007, at 9:31 AM, Stefan Heukamp wrote:

Hi,

in my Application I have two Windows which have slightly different MainMenues. This means each of them has 2 or 3 Menuitems which the other one doesn't have.
At the moment I remove and insert those items in the window's delegate's becomeKeyWindow and resignKeyWindow methods.
This is not very elegant and i get a lot of those loglines:


*** Assertion failure in -[NSMenu itemAtIndex:], Menus.subproj/ NSMenu.m:713
Invalid parameter not satisfying: (index >= 0) && (index < (_itemArray ? CFArrayGetCount((CFArrayRef)_itemArray) : 0))


These loglines are printed when I use keyboard-shortcuts. When I click the same Menuentries I do not get those errors.
The surprising thing is that there are no restrictions regarding the functionality. The only thing is that I do not like those loglines ;-)


What do these errors mean? Is it not possible to alter the mainmenu via insertItem and removeItem? Do I have to call any update- function after altering the mainmenu?

What would be the intended way to change the mainmenu the way I described? I looked at the NSMenuValidation-Protocol but it only grays out the not wanted menu items.
Should I build two Menues in the Interface Builder and only exchange them?


Thanks for any answer in advance,

Stefan

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Removing / inserting Menuitems in Mainmenu (From: Stefan Heukamp <email@hidden>)

  • Prev by Date: Re: Confused re unichar
  • Next by Date: Learn Cocoa: Part II
  • Previous by thread: Removing / inserting Menuitems in Mainmenu
  • Next by thread: Re: Removing / inserting Menuitems in Mainmenu
  • Index(es):
    • Date
    • Thread