• 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: NSMenu Trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenu Trouble


  • Subject: Re: NSMenu Trouble
  • From: Izon de Bartas <email@hidden>
  • Date: Sat, 13 Dec 2003 16:35:37 -0500

The problem with sending the message directly to the font manager is that I could still bold things, but not unbold them. Adding a bold trait to an already-bolded segment of text does not unbold it.

I was attempting to fire the menu item since it seems to mysteriously handle this itself (even though its tag and other information remains the same). I'm THOROUGHLY confused by this.

-IdB


On Dec 13, 2003, at 4:23 PM, Andreas Mayer wrote:

Am 13.12.2003 um 19:53 schrieb Izon de Bartas:

I'm trying to link toolbar items for bold, italic, and underline to their corresponding menu items for simplicity.

This seems wrong. A view should not depend on another view. Link it to the corresponding controller instead.

2 - Is there a better way of performing the bold / unbold automagically?

I'd do it the same way as the Format menu in IB:

For bold or italic send addFontTrait: to the shared NSFontManager.
For underline (or subscript, superscript, outline ...) send the corresponding message to the First Responder.

So for bold you send

[[NSFontManager sharedFontManager] addFontTrait:self];

and reply to the tag message with:

- (int)tag
{
return NSBoldFontMask;
}

About NSFontManager: http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/ObjC_classic/Classes/NSFontManager.html

For underline just send an underline: message up the responder chain

[NSApp sendAction:@selector(underline:) to:nil from:self];

About the Responder Chain: http://developer.apple.com/documentation/Cocoa/Conceptual/ BasicEventHandling/index.html?http://developer.apple.com/ documentation/Cocoa/Conceptual/BasicEventHandling/Concepts/ AboutRespChain.html

I didn't try this myself, so no guarantees whatsoever. :}


bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSMenu Trouble
      • From: Andreas Mayer <email@hidden>
References: 
 >NSMenu Trouble (From: Izon de Bartas <email@hidden>)
 >Re: NSMenu Trouble (From: Andreas Mayer <email@hidden>)

  • Prev by Date: NSWindowController
  • Next by Date: Re: NSWindowController
  • Previous by thread: Re: NSMenu Trouble
  • Next by thread: Re: NSMenu Trouble
  • Index(es):
    • Date
    • Thread