• 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
NSButton draws unwanted white background on overlay window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSButton draws unwanted white background on overlay window


  • Subject: NSButton draws unwanted white background on overlay window
  • From: Felix Schwarz <email@hidden>
  • Date: Wed, 30 Nov 2005 00:34:42 +0100

Hi,

I want to display a transparent overlay window like i.e. appears if you change the system volume via the keyboard. Therefore I create it with

if (window = [[NSWindow alloc] initWithContentRect:NSMakeRect (0.0,0.0,windowWidth,windowHeight)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO])
{
[window setBackgroundColor: [NSColor clearColor]];
[window setLevel: NSStatusWindowLevel];
[window setAlphaValue:1.0];
[window setOpaque:NO];
[window setHasShadow: NO];


	...
	}

and set an instance of an NSView subclass as content view, that does nothing else but override the drawRect method:

- (void)drawRect:(NSRect)rect
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGRect fitInRect;

[[NSColor clearColor] set];
NSRectFill([self frame]);


	CGContextSetRGBFillColor(context,0.30,0.30,0.30,0.25);

	fitInRect = QuartzToolsDrawRoundBox (	context,
						NSRectX1(rect), NSRectY1(rect),
						NSRectX2(rect), NSRectY2(rect),
						20.0);

	CGContextFillPath(context);
}

to draw the round box. Then, I also add an NSButton, so the user can close the dialog that I want to create this way:

if (doneButton = [[NSButton alloc] initWithFrame:NSMakeRect (windowWidth-40.0-100.0, 20.0,
100.0, 32.0)])
{
[doneButton setTitle:@"Close"];
[doneButton setButtonType:NSMomentaryPushButton];
[doneButton setImagePosition:NSNoImage];
[doneButton setBezelStyle:NSRegularSquareBezelStyle];
[doneButton setFocusRingType:NSFocusRingTypeNone];
[doneView addSubview:doneButton]; // doneView is the content view
[doneButton release];
}


Everything displays nicely first:

	http://www.wapapp.de/before.png

but turns into the opposite as soon as I press the NSButton:

	http://www.wapapp.de/after.png

How can I avoid the white background / border drawing done by NSButton?

Thanks in advance for any help.

Felix
_______________________________________________
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


  • Prev by Date: Re: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ?
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: NSImageView + Text
  • Next by thread: NSTextView and setUsesFontPanel:
  • Index(es):
    • Date
    • Thread