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: Nik Sands <email@hidden>
- Date: Fri, 28 May 2004 12:55:54 +1000
Thanks Glen,
Your #2 option looks like it's close to the mark, but I still cannot
get it to work. Your example appears to be very different to my
case... I don't think you're using an accessoryView in the NSFontPanel,
as I'm trying to do.
Ie, The text view for which I want to manage fonts/sizes/etc is
actually added to the sharedFontPanel window (as it's accessoryView).
So I have only one window on screen, which includes the normal
NSFontPanel content, PLUS the additiona text view(s) that I've added to
it.
So I then want to be able to select some text from the added text view,
and choose a different font/size/etc, and have the text view updated as
I do so. Currently this does not work, because as soon as I click on a
font/size/etc from the panel, the clicked object, etc becomes the
window's first responder, and the message never gets to the text view.
In theory, your suggestion should work around this. I've tried
changing the NSFontManager's action to a custom action in my
application delegate ("changeFontForAccessoryView"), but that action
never get's called (I've got an NSLog there to check).
Any ideas?
Thanks,
Nik.
On 27 May 2004, at 10:51 AM, Glen Low wrote:
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.