Re: NSCell interiorBackgroundStyle wrong?
Re: NSCell interiorBackgroundStyle wrong?
- Subject: Re: NSCell interiorBackgroundStyle wrong?
- From: Seth Willits <email@hidden>
- Date: Fri, 31 May 2013 13:42:47 -0700
On May 31, 2013, at 1:25 PM, Kyle Sluder wrote:
> If you override -highlightColorWithFrame:inView:, you also need to
> override -interiorBackgroundStyle. NSCell doesn't look at the return
> value of -highlightColorWithFrame:inView: to determine whether it has a
> light or dark background.
After having been looking at this and more for a further two hours, in retrospect the issue is minor and somewhat logical. If you override one, you simply are expected to override the other, but the undocumented relationship just caught me off guard. I'll file a report on that.
And as I've now discovered in my further exploration, -interiorBackgroundStyle is used for double duty. Not only is used to describe the *cell's* background, it's also used to describe the *field editor's* background during editing. THAT is weird and undocumented.
In my case, since the cell does not draw its own background, the interiorBackgroundStyle should simply be whatever the backgroundStyle is, right? If the background is dark, then the cell's interior background is effectively dark, and the cell should draw in light colors. However, literally returning the self.backgroundStyle from -interiorBackgroundStyle is incorrect because when you start editing the cell, the field editor will be using Light color text since editing calls the private method _textAttributes which uses the opposite of interiorBackgroundStyle to determine the text color. (iBS is dark so it uses white in the field editor.)
So the correct solution involves overriding the editing-related methods and setting an internal flag to know when editing is happening, and return NSBackgroundLight when editing, otherwise return self.backgroundStyle. Ugh.
I think _textAttributes should be made public, especially given that -attributedStringValue is never even called.
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden