• 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: godefroy <email@hidden>
  • Date: Tue, 25 Nov 2003 18:07:11 +0100

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.

  • Follow-Ups:
    • Re: Communication between an NSView and AppController;
      • From: Matt Budd <email@hidden>
References: 
 >Communication between an NSView and AppController; (From: Matt Budd <email@hidden>)

  • Prev by Date: Re: Cocoa Target Remains NULL
  • Next by Date: Re: Localized alert function?
  • Previous by thread: Communication between an NSView and AppController;
  • Next by thread: Re: Communication between an NSView and AppController;
  • Index(es):
    • Date
    • Thread