Re: NSFontPanel act on it's own accessory view?
Re: NSFontPanel act on it's own accessory view?
- Subject: Re: NSFontPanel act on it's own accessory view?
- From: Glen Low <email@hidden>
- Date: Thu, 27 May 2004 08:51:27 +0800
Nik:
On 26/05/2004, at 6:13 PM, email@hidden wrote:
Message: 3
To: email@hidden
From: Nik Sands <email@hidden>
Subject: NSFontPanel act on it's own accessory view?
Date: Wed, 26 May 2004 14:36:23 +1000
Currently, when my application wants the user to be able to edit some
default text attributes, it opens a window containing some default
text, and the shared font panel, [NSFontPanel sharedFontPanel].
What I would like to do is to have the default text appear within a
view that is added to the shared font panel as it's accessory view (ie,
[[NSFontPanel sharedFontPanel setAccessoryView:defaultTextView]).
However, when I try this, anything the user does in the font panel has
no effect on the selected text in the accessory view.
NSFontPanel sends the changeFont: message down the responder chain when
the user selects a different font. So, you either have to:
1. Ensure the text view is on the responder chain at all times -- this
may be difficult to do. Try making the font panel key... but as soon as
the user clicks on something else that bears text, you will lose it,
although this is the "expected" behavior.
2. Reroute the changeFont: message. You can change the message to say
changeMyFont: (use setAction: on the NSFontManager), then use your
delegate (window or application) or appropriate control to grab it and
route it to the text view.
I don't know from your application design but it sounds as if you want
the font panel to get the text and fonts when the user selects
something. If so, the second approach sounds correct, but you'll have
to be careful about all the times the selected object "goes in front"
(and/or "goes to the back") e.g. when its window becomes main or key,
when makeFirstResponder: called, if in a table view when it gets
selected, etc.
If you want an example of #2, my PGFontColorTable does this (although
still a little too invasively for my liking). Go to www.graphviz.org
and download the Graphviz sources and look in the mac/gui directory;
the program itself is at:
http://www.pixelglow.com/graphviz/.
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
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.