• 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: Better way to deal with NSFontPanel in a preference pane
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Better way to deal with NSFontPanel in a preference pane


  • Subject: Re: Better way to deal with NSFontPanel in a preference pane
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 16 Feb 2004 00:45:52 -0500

On Feb 16, 2004, at 12:07 AM, Sailor Quasar wrote:

This isn't a problem in the sense that I have no solution to it, but it's nagging at me because of the hack I had to do to make it work.

Basically, I have a button in my preference pane that shows the Font panel. The Font panel, on user selection, sends a -changeFont: message up the responder chain. I need it to send the message to a delegate, because the idea is to store a font and size (and attributes etc.) for later use by the faceless background app the pane controls. Since I don't have direct access to the responder chain for System Preferences, naturally, my solution was to create a subclass of NSResponder, manually insert it into the responder chain (just before [NSApp mainWindow] and set its nextResponder to the original one), and have it call back into my pane controller.

This works reliably, but it feels like a hack. Is there a better way to pick a font for later use? I don't want to have to implement a font menu, a size menu, an attributes menu... that's what the font panel is for!


Yes, it is.

what I've done in the past is in a controller class that is a subclass of NSWindowController, get the window of the text field that I display the font in, and then make it the first responder (which should be me) then explicitly order the Font panel front.

- (void)changeTextFont:(id)sender
{
[[self window] makeFirstResponder:[fontTextField window]];
[[NSFontManager sharedFontManager] orderFrontFontPanel:self];
[[NSFontManager sharedFontManager] setSelectedFont:[self font] isMultiple:NO];
}


This is much more straight forward in a non preference pane situation mind you.. :-)
_______________________________________________
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: Better way to deal with NSFontPanel in a preference pane
      • From: Ryan Bates <email@hidden>
References: 
 >Better way to deal with NSFontPanel in a preference pane (From: Sailor Quasar <email@hidden>)

  • Prev by Date: ScalingScrollView with Sketch
  • Next by Date: Re: NSImage and flipping
  • Previous by thread: Better way to deal with NSFontPanel in a preference pane
  • Next by thread: Re: Better way to deal with NSFontPanel in a preference pane
  • Index(es):
    • Date
    • Thread