• 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: Andreas Mayer <email@hidden>
  • Date: Sat, 13 Dec 2003 22:23:40 +0100

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.

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

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