• 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
How Can I Notify DrawRect Method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How Can I Notify DrawRect Method?


  • Subject: How Can I Notify DrawRect Method?
  • From: "Chunk 1978" <email@hidden>
  • Date: Tue, 9 Dec 2008 11:17:59 -0500

i'm assuming this is simple, but i can't solve the problem. at launch
of the application, an NSRect is drawn with a userdefault color:

-=-=-=-=-
- (void)drawRect:(NSRect)rect
	{
	NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSData *colorAsData;
	colorAsData = [defaults objectForKey:@"aColor"];
	NSColor *menuBarColor = [NSKeyedUnarchiver
unarchiveObjectWithData:colorAsData];
	[menuBarColor set];
	NSRectFill([self bounds]);
	}
-=-=-=-=-

that works... but now i want that rect to redraw itself when notified
to do so, but i can't figure out how to notify the NSRect to draw
again... all my NSUserDefaults colorAsData is in place, as well as my
NSNotifications.  it will print to NSLog so i know that notification
is being called, but how do direct that notification to the drawRect
method?

-=-=-=-=-
- (void)awakeFromNib
	{
	[MenuBarWindow setAlphaValue:0.0];

	NSNotificationCenter *notificationCenter = [NSNotificationCenter
defaultCenter];
	NSString *changeColorNotification = @"changeColorNotification";
	[notificationCenter addObserver:self selector:@selector(changeColor:)
changeColorNotification object:nil];
	}

- (void)changeColor:(NSNotification *)notification
	{
	NSLog(@"Call drawRect");
	//call "drawRect:(NSRect)rect" method
	}
-=-=-=-=-
_______________________________________________

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: How Can I Notify DrawRect Method?
      • From: "I. Savant" <email@hidden>
    • Re: How Can I Notify DrawRect Method?
      • From: rajesh <email@hidden>
    • Re: How Can I Notify DrawRect Method?
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Printing File to PDF from Native Application
  • Next by Date: Text Not Anti-Aliased In NSView
  • Previous by thread: Re: ASLExpireTime Format? [Solved, somewhat]
  • Next by thread: Re: How Can I Notify DrawRect Method?
  • Index(es):
    • Date
    • Thread