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

background color of NSTextView


  • Subject: background color of NSTextView
  • From: email@hidden
  • Date: Mon, 12 Feb 2007 17:42:15 +0100 (CET)
  • Importance: Normal

       Hello all,

  I'm trying to produce a text view that displays a (variable) background
color on-screen
only, so that I cannot use the setBackgroundColor: method of NSTextView
directly. I had the following two ideas, which both failed (in both cases
the background color of the text view is still blank at run-time):

   1) Create a subclass ColoredTextView of NSTextView :


@interface ColoredTextView : NSTextView {
        NSColor* backgroundScreenColor;
}
-(void) setBackgroundScreenColor : (NSColor*) aColor;
@end

whose drawRect method is as follows :

- (void)drawRect:(NSRect)rect {
	if ([[NSGraphicsContext currentContext] isDrawingToScreen]) {
		[backgroundScreenColor set];
		[NSBezierPath fillRect:rect];
	}
	[super drawRect:rect];
}

 2) Create an auxiliary "unicolored" NSView whose frame is the same as the
text view.

                                What is the correct solution ?


                                               Ewan




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

  • Prev by Date: How to set scheduling in NSThread based application
  • Next by Date: Re: CVS
  • Previous by thread: Re: How to set scheduling in NSThread based application
  • Next by thread: Core Data, bindings and synchronizing.
  • Index(es):
    • Date
    • Thread