Controlling a CustomView
Controlling a CustomView
- Subject: Controlling a CustomView
- From: Nathan Wertman <email@hidden>
- Date: Wed, 5 Mar 2003 09:57:58 -0700
NEWBIE WARNING!!!!
I am new to Cocoa programming and I have the following question: What
is the best way to control a custom view object from outside the custom
view object?
I have a custom view (StretchView) that draws a rectangle with a
background color, and a bunch of random lines over that background. I
also have an instantiated class that contains two actions:
changeFgColor and changeBgColor. I have registered the StretchView
object to 'listen' for the notifications NCWChangeBGColor and
NCWChangeFGColor.
This setup works just fine...the problem is that I feel like I am
leveraging notification for a task that they are not designed for. Is
there a way to have an NSColorWell or an NSButton that can connect to a
function in a custom view class? I really don't think that I need 2
seperate objects for such a simple application but I can't figure out
how to make the NSButton call the StretchView's changeBgColor function
without using a notification.
Attached below is a tar.gz'd version of the project if you would like
to poke around and see what I mean. Most of the code is pulled from
Aaron Hillegass's book 'Cocoa programming for Mac OS X'.
Nate
PS: this is the first time I have 'distributed' a project. If there is
a better way or if there is something wrong with this project please
let me know...
[demime 0.98b removed an attachment of type application/x-gzip which had a name of ImageFun.tar.gz]
_______________________________________________
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.