Re: NSPopUpButtonCell -- I need an outlet to gain access to the button
Re: NSPopUpButtonCell -- I need an outlet to gain access to the button
- Subject: Re: NSPopUpButtonCell -- I need an outlet to gain access to the button
- From: Dalton Hamilton <email@hidden>
- Date: Wed, 16 May 2007 14:04:27 -0400
On May 16, 2007, at 1:54 PM, I. Savant wrote:
Dalton:
My objective is to give the user three possible choses in a table
column. So, I'd like to simply provide a popup type button that
provides the valid options for them to chose from. If you think I
should do this another way, please let me know -- I've only got a
couple days into the code at this point.
While I understand you have a time constraint, with respect, it has
nothing to do with getting your problem solved. :-) I wasn't
suggesting not using a popup button, but if you're allowing users to
edit cells that are in a row in a table view,
-tableView:setObjectValue:forTableColumn:row: *is* how it's done.
Sorry for any miscommunication. I'm not in a time constraint. My
comment was that I've only been working on this version for 2 days.
So, it wouldn't be that bad if I tossed what I've got so far and
starting looking at Bindings.
It works generally the same way for setting an object's attribute
based on a selection in a popup as it does for setting a string in a
normal text field cell.
See:
http://www.cocoadev.com/index.pl?NSTableViewTutorial
http://www.cocoadev.com/index.pl?AnotherNSTableViewTutorial
Given your description, the above links *are* the solution to your
problem. This is exactly what you need to do, with a slight
modification / consideration since the "object" handed to you in
-tableView:setObjectValue:forTableColumn:row: may not be exactly what
you expect. Just set a breakpoint in that method and examine the
"object" the popup is handing you to make sure it's what you're
expecting. You'll figure it out.
As for Bindings, I've never used them. I've taught myself Cocoa a
few years back and all the examples and samples I taught myself with
were this model -- i.e. not Bindings.
Then you're using the NSTableViewDatasource methods. I suggest
reading the articles above and searching the documentation for
"NSTableViewDatasource". Whether you only have a few days or not, you
still have to do it right ... best to just take the time to read the
manual before wasting days barking up the wrong tree (in the wrong
forest).
I've read a few articles regarding Bindings and they seem much faster
but also for the person who isn't an expert and someone working and
teaching themselves as they write apps for various reasons, Bindings
can be much harder to debug -- or it looks that way.
I'm curious to know what article you're referring to regarding the
"person who isn't an expert" part. This is completely incorrect. Cocoa
Bindings relies on several other "moderate" to "advanced" Cocoa skills
like Key Value Coding and Key Value Observing. These topics are not
for Cocoa newbies.
Yes, that is what I was saying. I was simply saying that for a
novice without much help around them, Bindings may be taking a big
step -- especially in the areas of debugging. I've worked through a
couple small sample code projects I found on the web and the app
worked but after that I was stuck with what I had. In other words,
when you give up all the "glue" code etc you lose some control -- or
at least a novice does. To regain that control you need to know what
you're doing in Bindings and be good at fully understanding how it
works. But following the code samples, it all looks easy -- it is
the enhancements that would kill me.
Again, I do thank you for your time and suggestions.
Bindings *can* be hard to debug, yes, but knowing the technology
(and its supporting technologies) well will avoid most of the
hard-to-debug problems. Bindings and KVO can eliminate a lot of
glue-code, but they're not a solution to everything (in fact they're
rather counterintuitive in some situations). Either way, that's
irrelevant for your particular problem since you're not using
Bindings. :-)
If I wanted to start moving toward "Bindings" do you have a
recommendation of where I should start? Doing a quick search on how
to use NSPopUpButtonCell with Bindings, I found the following URL:
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Tasks/onerelation.html
I'll give it a try.
http://www.cocoadevcentral.com
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden