• 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
Docbased, NSViews, and Transparency.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Docbased, NSViews, and Transparency.


  • Subject: Docbased, NSViews, and Transparency.
  • From: email@hidden
  • Date: Wed, 27 Feb 2002 10:58:22 EST

Hi, first of all i'm a newbie with Cocoa :)
What I'd like is a document-based application. The documents are windows
which only contains an NSTextView. I'd like the background of this NSTextView
to have a color with a specified alpha value, i mean, less or more
transparent. But I want the text of this NSTextView and the rest of the
window to be totally opaque.
I tried this :
- I subclassed NSDocument (MyDocument) and created a MyDocument.nib with an
empty window and a NSView containing only my NSTextView, which custom class
is set to a subclass of NSView : MyViewControl.... well, then i have an
outlet for my nstextview.

This code doesn't work :

In MyViewControl.m :

@implementation MyViewControl
- (void)drawRect:(NSRect)aRect
{
NSColor* c = [[Preferences prefsInstance] backgroundColor]; // this
return the background color the user defined is the prefs
[c set];
NSRectFillUsingOperation(aRect, NSCompositeSourceOver);
}

- (BOOL)isOpaque
{
return NO;
}
@end




and in MyDocument.m :
- (void)awakeFromNib
{
[[NSApp mainWindow] setOpaque:NO];
[[NSApp mainWindow] setContentView:myView];
[myTextView setDrawsBackground:0];
[myTextView setBackgroundColor:[[Preferences prefsInstance]
backgroundColor]];
[myTextView setTextColor:[[Preferences prefsInstance] textColor]];
[myDrawer setContentSize:NSMakeSize(417,50)];
[myView displayRectIgnoringOpacity:[myView frame]];
}

here, myTextView is the NSTextView, myView the NSView which contains it,
and, i guess [NSApp mainWindow] is the new window which has just been created
after newDocument: has been called....... myDrawer is a NSDrawer attached
to the window...
well, it doesn't work.... moreover, the NSTextView doesn't appear until i
created a newDocument. i mean if i create a first document, its myTextView
will only appear when i'll have created a second document, etc...


Thanks you in advance for your help :)
Nico.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: My apologies...
  • Next by Date: Re: Option key or Alternate key
  • Previous by thread: Re: My apologies...
  • Next by thread: Re: Option key or Alternate key
  • Index(es):
    • Date
    • Thread