I have multiple custom NSViews in my Cocoa program. I am looking for a way to force them to invalidate without having to add additional code while the program is running. If I were doing this with on Windows with the .NET framework, I would just drag part of my program offscreen and drag back on again. Areas that was offscreen get invalidated when they come back on screen. I haven't figure out how to do this with Cocoa - OSX.
views:
126answers:
4
+3
A:
The methods setNeedsDisplay
should do it:
- (void)setNeedsDisplay:(BOOL)flag
- (void)setNeedsDisplayInRect:(NSRect)invalidRect
Docs here
pgb
2009-09-01 21:37:37
My question was not clear. I want to cause invalidation while the program is running.
phi
2009-09-01 21:40:58
Are you looking to invalidate them via user action, or code?
Ben Gottlieb
2009-09-01 21:50:37
+1
A:
Windows on Mac OS X are buffered by the Window Server and can't be forced to redraw by moving them around the screen. The only way the user can force a redraw is to resize the window.
Why do you need to do this, though?
Rob Keniger
2009-09-01 23:49:52
A:
I recommend you try F-script http://www.fscript.org/. It allows you to call methods on Cocoa objects while your program is running.
You could use it to call the setNeedsDisplay:(BOOL)flag
or setNeedsDisplayInRect:(NSRect)invalidRect
methods directly on the view you would like to invalidate.
Ira Cooke
2009-09-02 06:59:43