Re: Communication between an NSView and AppController;
Re: Communication between an NSView and AppController;
- Subject: Re: Communication between an NSView and AppController;
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 25 Nov 2003 15:37:50 -0800
Hello...
Have you thought about adding an IBOutlet to your NSView subclass so
that the view also connects to your appController instance (in
addition to the connnection you made from the appController to the
customView) ?
If your window is loaded from the MainMenu.nib, you would need to
instantiate your AppController object in that nib using Interface
builder if you haven't already, so that you can make the connections.
That way either object knows how to talk to the other (which would
also possibly require adding a method to AppController to be called
when your color/shape update occurs...)
Louis
I thought that the whole action/target architecture only applied to
NSControl's and their subclasses (NSButton, NSColorWell, etc.). My
object is a subclass of NSView (NSControl's superclass), so I didn't
think I could use an action/target. I have no target outlet for my
canvas, and no way to specify when the action triggers the target
selector (i.e on mouse click, mouse drag, or perhaps something else).
I'm fairly new to Cocoa and Objective-C, so maybe I kind of
misunderstand this. Could you give a brief description on how I can
use an action in this case?
Thanks for any info...
- Matt
On Tuesday, November 25, 2003, at 10:07 AM, godefroy wrote:
i think you just need to use action.
if you want that many object receive the equivalent of an action
you should use notification
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.
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.