• 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
Drawing to a hidden view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing to a hidden view


  • Subject: Drawing to a hidden view
  • From: Michael Norris <email@hidden>
  • Date: Mon, 18 Aug 2003 15:37:46 +1200

Hi there

I've come across a small puzzle. In my NSWindow I have a custom NSView
which displays some graphics. When the NSWindow is closed, I want to
erase the view's rect, so that when the window is displayed again you
don't see what was in there previously.

Trouble is, when I tell the view to erase itself just before the window
closes, it doesn't seem to affect the view's display. I even try to
re-erase it upon reshowing the window. Yet when the window is reshown,
the old data is still there.

I've tried adding a -lockFocus and -unlockFocus to my redraw routine,
without any change.

Any thoughts gratefully accepted.

Here's the code:

in the view:
// this view is called scoreView
- (void)clear {
NSEraseRect([self bounds]);
[self setNeedsDisplay:YES];
}

in the window controller class:

// this method called when reshowing the NSWindow
- (void)showWindow {
[scoreView clear]; // to be doubly sure
[[self window] display]; // trying the brute force method, without
success
[[self window] centerOnScreen:[NSScreen mainScreen]]; // a category
[[self window] makeKeyAndOrderFront:self];
[self showNewQuestion]; // displays new data into the scoreView
}

// this method called when closing the NSWindow
- (IBAction)exit:(id)sender {
[(AppController*)[NSApp delegate] showMainWindow]; // show another
window first
[scoreView clear]; // erase the rect as above
[[self window] orderOut:self]; // hide the window
}





-mike
_______________________________________________
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: Re: line spacing of attributed string (was No Subject)
  • Next by Date: Re: Executing AppleScript from Cocoa (with return values)
  • Previous by thread: Re: Executing AppleScript from Cocoa (with return values)
  • Next by thread: Altering an existing menu item
  • Index(es):
    • Date
    • Thread