• 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
NSTextView translucency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView translucency


  • Subject: NSTextView translucency
  • From: "Mike R. Manzano" <email@hidden>
  • Date: Sun, 1 Oct 2006 00:13:08 -0700

I have drawn some imagery in an NSView. A child of that NSView is a custom NSTextView. I would like the background of the text view to be translucent so that the fully-opaque text is overlaid atop the imagery in the parent NSView.

I have appropriately overridden the text view's isOpaque to return NO. I have also overridden drawViewBackgroundInRect:to do nothing (so that a background is not drawn).

This has the appropriate behavior in that the text is overlaid on the background imagery. However, the text drawing system is now overlaying text on top of previously rendered text as it is no longer able to "erase" the old text (because drawViewBackgroundInRect no longer does anything).

My current strategy is to actually "erase" the rect passed to drawViewBackgroundInRect:. I've tried something like this:

- (void)drawViewBackgroundInRect:(NSRect)rect
	{
	[ [ NSColor clearColor ] set ] ;
	NSRectFill( rect ) ;
	}

The problem with this, obviously, is that it draws nothing, and the problem isn't fixed.

I then tried something like this:

- (void)drawViewBackgroundInRect:(NSRect)rect
	{
	[ [ NSColor whiteColor ] set ] ; //  Just so I know what color's set
	NSRectFillUsingOperation( rect, NSCompositeClear ) ;
	}

I was hoping that this would draw "clear pixels"; i.e., set all pixels in rect to have a 0 alpha value, thereby erasing anything that was previously drawn in rect. Instead, I get black.

Can anyone tell me how I can get Cocoa to draw "clear pixels" so that I can erase properly?

Less importantly, why would it draw black?

Regards,


~ Mike alephx01 (at) mac (dot) com





_______________________________________________
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


  • Next by Date: Delete on remove and NSArrayController: how to ?
  • Next by thread: Delete on remove and NSArrayController: how to ?
  • Index(es):
    • Date
    • Thread