• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSView subview backgrounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView subview backgrounds


  • Subject: Re: NSView subview backgrounds
  • From: Twisted Theory Software <email@hidden>
  • Date: Mon, 1 Oct 2007 13:22:04 -0500


On 1 Oct, 2007, at 1:06 PM, David Duncan wrote:

On Oct 1, 2007, at 10:42 AM, Twisted Theory Software wrote:

I have an NSView subclass, which is getting a gradient background, drawn by NSBezierPaths. I found that even though I'm drawing the background using colours with alpha component equal to 1.0, their colour is being effected by the colour of the object underneath it (which is black). I can check that this is true by using the DigitalColor Meter application.

Be careful how you interpret the results you get from DigitalColor Meter, they are the colors after the window server has done it's color matching, so you may not get the colors you expect, but they may also not be affected by the background...

What I mean is that between using a black background and drawing the white background, I can see, even visually, that the colours when using the white background are much lighter than without.



I found a workaround, to fill the view with a background white before drawing the horizontal gradient paths. Unfortunately, when I add NSButtons with transparent backgrounds as subviews, they appear as white squares in the view. I've noticed that once I resize the window, so that the view redraws, the button appears correctly. However, after it is pressed and released, the white square reappears (the button is just a momentary-light button, so it should return to the initial state).

Are you sure that your embedding hierarchy is correct? You might just be getting lucky at some times and not others, and the white rectangle your drawing might just be mimicking what is already occurring in the window.

I'm not sure, I don't know what an embedding hierarchy is. However, even adding one button programmatically, by creating the button and then [statusView addSubview:buttonInstance] results in the white background problem, every time. Again, setNeedsDisplay initially fixes the problem, but pressing the button instance causes it to reappear. I've considered subclassing the button and adding a call to [superview setNeedsDislay:YES] to the mouseDown method, but this seems overly hacky. I'm sure that this is a problem with my understanding of how views are drawn, which is minimal.


When drawing a subview with a transparent background, why does the white colour, set with

[[NSColor whiteColor] set];
[NSBezierPath fillRect:rect];

show up, and not the gradient background?

Thanks,

Josh
_______________________________________________

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


  • Follow-Ups:
    • Re: NSView subview backgrounds
      • From: David Duncan <email@hidden>
References: 
 >NSView subview backgrounds (From: Twisted Theory Software <email@hidden>)
 >Re: NSView subview backgrounds (From: David Duncan <email@hidden>)

  • Prev by Date: Re: NSView subview backgrounds
  • Next by Date: Re: Presenting NSLocalizedFailureReasonErrorKey
  • Previous by thread: Re: NSView subview backgrounds
  • Next by thread: Re: NSView subview backgrounds
  • Index(es):
    • Date
    • Thread