• 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
Re: Communication between an NSView and AppController;
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Communication between an NSView and AppController;


  • Subject: Re: Communication between an NSView and AppController;
  • From: Matt Budd <email@hidden>
  • Date: Tue, 25 Nov 2003 11:40:13 -0700

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.

References: 
 >Re: Communication between an NSView and AppController; (From: godefroy <email@hidden>)

  • Prev by Date: Opening a sheet in a non document project?
  • Next by Date: Double-clicking in NSOutlineView
  • Previous by thread: Re: Communication between an NSView and AppController;
  • Next by thread: Re: Communication between an NSView and AppController;
  • Index(es):
    • Date
    • Thread