Re: NSPanel vs. NSFontPanel and font color
Re: NSPanel vs. NSFontPanel and font color
- Subject: Re: NSPanel vs. NSFontPanel and font color
- From: Tom Harrington <email@hidden>
- Date: Fri, 28 Oct 2005 17:54:39 -0600
On 10/26/05, Tom Harrington <email@hidden> wrote:
> OK, I created a new app using the "Cocoa Application" template.
> Opened MainMenu.nib and added an NSTextView to the NSWindow that the
> project template includes. I added an NSPanel with its own
> NSTextView. I also made sure that both the panel and window were
> visible at launch, and added the standard Format menu. No other
> changes to the project template.
>
> When I build and run the application I can set the font style and size
> in both NSTextViews. I can set the text color in the NSTextView
> that's in the NSWindow-- select text, bring up the font panel, click
> the text color button, and then select a color from the color
> selector.
>
> If I try the same sequence for the NSTextView that's located in the
> NSPanel, the NSPanel loses focus as soon as the color-selection panel
> (presumably an NSColorPanel?) appears. Color change events are
> apparently not received by this NSTextView, because the color doesn't
> change.
>
> But if I then click in the NSPanel's NSTextView while the color
> selector is visible, color changing does work. This extra step is not
> necessary with the NSWindow's text view.
>
> I'm guessing that the appearance of the color-selection panel causes
> my NSPanel to drop out of the responder chain, and that clicking in
> the panel brings it back in. But I don't want the extra step to be
> necessary, so I guess what I really need is a way to intercept the
> color change somewhere and redirect it back to the NSTextView that
> should be receiving it. Or is there some better way?
Just for benefit of those searching the archives...
What I finally did was implement -canBecomeMainWindow in my NSPanel
subclass, so that it always returns YES. I know that's not typical
behavior for an NSPanel, but in this case it seems to make sense. I
didn't find any other way to deal with this for an NSPanel, but
fortunately allowing the panel to become the main view is OK in this
case.
As for why I don't just switch to NSWindow then, it's because
NSPanel's -setBecomesKeyOnlyIfNeeded: is necessary in this case.
Otherwise I wouldn't have bothered.
--
Tom Harrington
email@hidden
AIM: atomicbird1
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden