• 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: Ryan Bates <email@hidden>
  • Date: Mon, 16 Feb 2004 08:21:08 -0800

On Feb 15, 2004, at 9:45 PM, Scott Anguish wrote:
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 works great if an NSWindowController is controlling your preferences window, however, it sounds like he is loading an NSPreferencePane subclass into System Preferences. Unfortunately, NSPreferencePane is not a subclass of NSResponder and therefore cannot accept first responder status.

On Feb 15, 2004, at 9:07 PM, Sailor Quasar wrote:
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.


Rather then manually inserting the NSResponder subclass into the chain, try making it the first responder of the window:

[[mainView window] makeFirstResponder:customResponder];

The rest should work the same way.

Ryan
_______________________________________________
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.

References: 
 >Better way to deal with NSFontPanel in a preference pane (From: Sailor Quasar <email@hidden>)
 >Re: Better way to deal with NSFontPanel in a preference pane (From: Scott Anguish <email@hidden>)

  • Prev by Date: fileWrapperRepresentationOfType and PkgInfo
  • Next by Date: Sorting NSTableView with NSDictionary objects in Panther
  • Previous by thread: Re: 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