Communication between an NSView and AppController;
Communication between an NSView and AppController;
- Subject: Communication between an NSView and AppController;
- From: Matt Budd <email@hidden>
- Date: Tue, 25 Nov 2003 09:37:37 -0700
Hi..
I am writing a small drawing program that uses a custom NSView subclass
to draw the shapes on (squares, circles, etc.). I'm not using the
document architecture (with NSDocument), but instead have just created
a plain NSApplication project (my MainMenu.nib is my drawing
canvas)...I'm just doing a prototype now.
So I've created (and instantiated in IB) a custom NSObject subclass,
called AppController, to act as the controller for the NIB file. I've
set up an IBOutlet to my NSView (called Canvas), so I am able to
communicate in that direction (from the controller to the canvas). The
problem is I am not sure how to communicate the other way...
Some background on why I want to do this:
On the MainMenu.nib, I have color wells for foreground and background
color. When the user has drawn a shape, and then subsequently selects
it (I have all this logic done already), I want to refresh the color
wells to reflect the back/fore color of the current shape. Then if they
change the color of either of the wells, it changes the shape's. Like I
said, I think I can easily do the second part of that process (from
controller to canvas), but don't know how to inform the controller from
the canvas.
Ways I've though about:
- using notifications. Basically, in my canvas, I'd tell the
controller that something has changed and then I'd set a variable. The
controller could then read me and see what changed (again, that
direction of communication should be easy due to the IBOutlet I set in
IB).
- using 1st responder. Same idea as notifications, but using the
responder chain...
I'm not sure of the feasibility of either, or if there is a better
proper way to do this kind of thing. Any help or information would
really be appreciated...
Thanks,
Matt Budd
_______________________________________________
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.