Re: wits end with nsview and nsrectfill()
Re: wits end with nsview and nsrectfill()
- Subject: Re: wits end with nsview and nsrectfill()
- From: Navneet Kumar <email@hidden>
- Date: Sat, 13 Dec 2014 20:50:17 +0530
Hi
After trying out everything, I finally found how to remove that difference in background color.
I couldn’t find any rationale in this patch effect, so I turned the outline selection highlight to none (regular, i.e. plain white also works).
So if you take a view-based outline view (or maybe table view as well) and fill a table column’s view’s background with NSRectFill() or any other and add as sub view a transparent text field, upon refresh the text field and the rest of the background will differ in color as long as selection highlight is set to “Source List”. As if source list color superimposes on the area other than the text field.
But I still can’t understand the nitty gritty of this.
But in this solution, the outline view loses source list style color in its appearance.
Also I found that setting the background color does not lead to this patch.
Is there anyway I can still get the same source list style color in its appearance and not have this patch? If setting background color is the solution, how to get source list color without applying it?
Any ideas?
Wishes,
Navneet
> On 04-Dec-2014, at 8:13 pm, Navneet Kumar <email@hidden> wrote:
>
> Hi,
>
> The problem is not there if I create a new project and add a text field as subview to a custom view with a background color. There is no difference in color in text field and rest of the area.
>
> And also this wasn’t there a couple of months ago, and not using git or subversion, I am not able to locate what I did to get to the current problem.
>
> Any ideas what could be happening?
>
> Can I get clear on some things?:
>
> 1. If a view is send the msg -display, is the msg sent to all its subviews without exception?
> 2. Could it be that so many views when trying to display (in the main thread of course), could block some views from refreshing altogether?
>
> If I could get a few pointers, I might get to the bottom of this problem.
>
> Best,
> Navneet
>
>> On 01-Dec-2014, at 11:28 am, Navneet Kumar <email@hidden> wrote:
>>
>> Thanks for the responses.
>>
>> The problem is still there.
>>
>> I don’t need to dynamically add or remove views and was following the wrong way to setup view hierarchy in drawRect:.
>>
>> I have changed it to the following order: initWithFrame: then -(void)setupSubViews in all related classes.
>> So in app delegate I call initWithFrame: and then immediately setupSubViews. The entire view comes to front a lot later.
>>
>> The view hierarchy is complex, starting with a view based outline view, then child of a root node has box views (2 in a row). Every box has this bottom view which has this problem. I’m adding a non-selectable, non-editable text field with setDrawsBackground set to NO, as a subview to this bottom view.
>>
>> In drawRect:, I’m just using NSRectFill() with:
>>
>> NSColor *bgColor = [[NSColor blackColor]blendedColorWithFraction:0.25 ofColor:[NSColor whiteColor]];
>> [bgColor set];
>> NSRectFill([self bounds]);
>> And initially the background is same in text field and rest of the area. but on refresh, the rest of the area becomes darker, which shouldn’t be as NSRectFill() is supposed to draw opaquely.
>>
>>
>> Thanks,
>> Navneet
>>
>>
>>> On 30-Nov-2014, at 11:24 pm, Kyle Sluder <email@hidden> wrote:
>>>
>>> On Nov 30, 2014, at 9:30 AM, Navneet Kumar <email@hidden> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a custom view in which I am setting the background using NSRectFill() in drawRect:.
>>>
>>> You’re aware that this function is only really suitable for drawing opaque colors, yes? If you NSRectFill() with a transparent color, it will not blend that color with the existing backing store. Instead, it will replace all pixels in that rect with transparent ones, obliterating any drawing performed by ancestor views in the hierarchy.
>>>
>>>> I am also adding a text field as subview in this method.
>>>
>>> This is not allowed. -drawRect: is for drawing, not mutating your view hierarchy.
>>>
>>> If you want to position/install views at the last possible second before the drawing pass, use -viewWillDraw. But you have not offered any reasons why you need to dynamically add or remove views at all, much less in tandem with the drawing pass.
>>>
>>> --Kyle Sluder
>>
>> _______________________________________________
>>
>> 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
>
>
> _______________________________________________
>
> 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
_______________________________________________
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