Re: Bindings Basics: selections
Re: Bindings Basics: selections
- Subject: Re: Bindings Basics: selections
- From: Michael Carter <email@hidden>
- Date: Wed, 1 Jun 2005 07:40:16 -0700
Hey Niko.
Good news is, you are on the right path and everything is working:
you just aren't seeing the correct results due to a missing binding. :)
If you replaced your popup with an NSTableView you'd see that
everything was working fine. Bindings with popup controls is a little
different than with other view objects. In your case, you bound the
contents of the popup to be the arranged objects from your mailboxes
array, which was fine. You also bound your columns in the tableview
to the emails array of the selection from the popup, which was fine.
The last piece, which connects the other two together, is that you
need to bind the *index* of the popup as well.
In IB, add this additional binding to the popup button: Bind
selectedIndex to the Mailboxes controller with the key
"selectionIndex" and you will see the emails for the selected mailbox
properly.
#mikec
On May 31, 2005, at 3:01 PM, Niko Matsakis wrote:
Okay, so I read these links that you posted. I also took a
"bindings only" example (the Mailboxes program from
cocoabuilder.com that is used to introduce bindings) to eliminate
core data and stripped it down to the bare essentials. No dice.
As a reminder, I am trying to have the selection from a
NSPopUpButton determine what is displayed in a NSTableView.
I still cannot get this to work. I have posted the project at
http://smallcultfollowing.com/MailDemo.zip.
Basically all I have is an NSPopUpButton whose content is drawn
from one ArrayController. Then there is a second ArrayController
who is set to be "selection.emails" from the first ArrayController,
and an NSTableView which draws its content from arrangedObjects of
the second ArrayController.
The symptom is that changing the selection in the NSPopUpButton
does not cause the NSTableView to refresh its data. Any clue how
to fix this?
I still feel that there is some very basic confusion on my part
about what it means to make a binding. It seems to be some kind of
both an input and output relationship, and quasi-magical about what
kinds of messages it sends, etc. I guess I expect more clarity and
division: i.e., I would expect to have to set up a binding for
where to draw content from, then another binding where the
NSPopUpButton has some sort of output which connects to an input on
the NSArrayController in order to specify the current selection for
the NSArrayController. But instead they all seem to come at once.
Also, in the manual it mentions for table views certain bindings
for the table as a whole are made automatically based on the first
column's bindings, but I don't see that in IB. Do those bindings
that happen at runtime?
As a bonus question: Is there any way to turn on debugging output
for bindings to get a clearer picture of what's going on "under the
hood?"
thanks in advance,
Niko
On May 30, 2005, at 1:39 AM, mmalcolm crawford wrote:
On May 29, 2005, at 2:50 PM, Niko Matsakis wrote:
I do not understand how a selection gets set in Core Bindings. [...]
I have seen several examples that have an NSTableView, and use
the selection in the table view to populate some other fields.
This is the default interface generated by Option-Dragging a Data
Model into IB, for example. Unfortunately, I just don't get how
it works.
In this case, the "detail" fields which are being populated (that
contain the details of the current entry), always refer to the
array controller and use a path like "selection.xxx".
To understand what bindings are and how they work, read:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/WhatAreBindings.html>
then
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/HowDoBindingsWork.html>
It's not clear to me how selection is set; [...] It must be that
the NSTableView automatically adjusts the selection of its
Content Set Array Controller through some means, because I can't
find where it's being asked to.
If you simply bind the value of a table column, the content,
selectionIndexes, and sortDescriptors bindings are established
automatically for you. When the user makes a selection in a view,
the view messages the controller to update the selection
automatically.
if there are multiple NSTableViews using a given controller, for
example, whose selection is set? (or is the answer "don't do that")
Don't do that.
Does it work differently if it is a NSPopUpButton that is reading
from the array controller? Does it not set the selection? Can I
make it do so?
It works in fundamentally the same way.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden