Re: Dynamically update drawRect
Re: Dynamically update drawRect
- Subject: Re: Dynamically update drawRect
- From: proger proger <email@hidden>
- Date: Sun, 27 Dec 2009 14:22:20 +0200
Hello,
Sorry for such newbie questions. With IB i added NSView Custom Object:
http://grab.by/1peO . And i made IBOutlet:
@interface testViewAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet NSView *customView ;
}
I wrote such code for make NSRect and change color:
(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSRect frame = NSMakeRect(10, 10, 100, 100) ;
[[NSColor blueColor] set];
[NSBezierPath fillRect:frame];
[customView setNeedsDisplayInRect:frame];
}
But the problem is that NSRect is added to Window and not to my Custum View
http://grab.by/1peS . How to solve that NSRect would be added to my Custom
View. I think i doing something wrong, because NSWindow and Custom View is
different contexts.
Thanks
On Sun, Dec 27, 2009 at 2:10 PM, Quincey Morris <email@hidden
> wrote:
> On Dec 27, 2009, at 01:18, proger proger wrote:
>
> > I'm still don't know how to do it. As solution i see programmically
> create MyView class and call drawRect function as i needed. Because now
> MyView(NSView) is created by nib. And i can't call MyView class instance
> methods. How to programmically add Custom View and set MyView class ?
>
> I think the piece of information you're missing is that, in Interface
> Builder, when you drag a custom view "object" into a window, you can then
> set the *class* of the custom view to any NSView subclass that's defined in
> your project (such as "MyView", if that's what you've called it).
>
> Then, since your custom view is in a nib, you'll need a way of referring to
> it. Normally, you'd add an outlet to the nib's File's Owner object, and
> connect that to your view.
>
> That gives you what you need: a custom view created automatically when the
> nib is loaded, plus a reference to the custom view that you can use for
> sending messages to.
>
> Further references:
>
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/SubclassingNSView.html#//apple_ref/doc/uid/TP40002978-CH7-SW4
>
> http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/EditingNibFileObjects/EditingNibFileObjects.html#//apple_ref/doc/uid/TP40005344-CH12-SW31
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW19
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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