• 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: NSMenuItem’s userKeyEquivalent lost if changing title
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenuItem’s userKeyEquivalent lost if changing title


  • Subject: Re: NSMenuItem’s userKeyEquivalent lost if changing title
  • From: Kyle Sluder <email@hidden>
  • Date: Tue, 20 Sep 2016 19:55:38 -0500

On Tue, Sep 20, 2016, at 02:56 AM, Allan Odgaard wrote:
> Minor improvement on the code below, when title is equal to plainTitle
> we can set attributedTitle to nil.
>
> This restores proper rendering of disabled items.
>
> Finder should be able to do the same, as when its dynamic menu items are
> disabled, they would normally not contain the dynamic part (info about
> selected items).

Sounds like a great UI bug report to file, Allan. :)

--Kyle Sluder

>
>
> On 20 Sep 2016, at 9:37, Allan Odgaard wrote:
>
> > Thanks, I’ll switch to using this category method for setting
> > dynamic titles:
> >
> > - (void)setDynamicTitle:(NSString*)plainTitle
> > {
> > 	if(self.userKeyEquivalent && ![self.userKeyEquivalent
> > isEqualToString:@""])
> > 	{
> > 		NSString* title = plainTitle;
> > 		plainTitle = self.title;
> >
> > 		NSFont* font = self.menu.font ?: [NSFont menuFontOfSize:0];
> > 		self.attributedTitle = [[NSAttributedString alloc]
> > initWithString:title attributes:@{ NSFontAttributeName : font }];
> > 	}
> > 	self.title = plainTitle;
> > }
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >NSMenuItem’s userKeyEquivalent lost if changing title (From: Allan Odgaard <email@hidden>)
 >Re: NSMenuItem’s userKeyEquivalent lost if changing title (From: Dave Lyons <email@hidden>)
 >Re: NSMenuItem’s userKeyEquivalent lost if changing title (From: Allan Odgaard <email@hidden>)
 >Re: NSMenuItem’s userKeyEquivalent lost if changing title (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: Success with NSTableView weak delegates?
  • Next by Date: Re: Passing param by reference then using within block throws exception
  • Previous by thread: Re: NSMenuItem’s userKeyEquivalent lost if changing title
  • Next by thread: How to Launch an App using the Bundle ID?
  • Index(es):
    • Date
    • Thread