Saturday, December 16, 2017

#1 2009-09-18 06:25:24 am

robdut
Member
Registered: 2009-09-02
Posts: 301

binding user defaults to a table view selection

Hi all,

I am just throwing this out there.

My old ASS app has two table views, one a list of sets and the other a list of files for each set. I had this set up in ASS using some connected lists and parsing items into respective tables. Not the best but it worked. I also had some user options (default values) pertaining to each set of files. These change (along with the file list) as User changes sets.

I have found an excellent tutorial on Cocoa Dev about bindings and linking table views in particular:

http://www.cocoadevcentral.com/articles/000080.php

But is it possible to bind the user default values (checkboxes etc.) to the "Sets" selection also . I have been reading the bindings docs and trying to gain some ground here. In other words - managing different sets of user options.

I am addicted to bindings now but already pushing my abilities to the limit and getting over my head with Cocoa programming.

ASOC is starting to seem like pandora's box!

If any one has a pointer for me.... this will be an ongoing experiment and would bring my old big ASS app to a much better place.

Rob

Offline

 

#2 2009-09-18 06:36:33 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: binding user defaults to a table view selection

If I understand you correctly, the answer is no -- you can only bind the attributes of interface items to user defaults, not the other way around.

robdut wrote:

I am addicted to bindings now


They're like that -- so much power, so little code...


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2009-09-18 08:00:00 pm

robdut
Member
Registered: 2009-09-02
Posts: 301

Re: binding user defaults to a table view selection

Hi Shane,

I think I may have got the question wrong. It's not that I want to bind User defaults to a table's selected row, I want to bind the value of interface items (a checkbox for example) to the selected row. I meant "User preferences" rather than defaults.

so a user might have in a table that lists sets 1,2 3 etc.

Table
Set1   > checkbox1:true  checkbox2;false   textField1: "Hello"
Set2   > checkbox1:false   checkbox2;true   textField1: "World"
Set3   > checkbox1:true   checkbox2;true   textField1: "brown fox"

So different sets have different UI elements values associated with them. Presumably there would then be some way to archive the sets with their associated user preferences.

What I am actually doing with this app is creating a table of "backup sets." Each set has a list of files displayed in another table and different options for each particular set. I can hook up the two tables with bindings using two array controllers but also want to "hook" up the user's options for each set.

Hope that explains it better....

Rob

Offline

 

#4 2009-09-18 10:43:15 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: binding user defaults to a table view selection

robdut wrote:

I think I may have got the question wrong. It's not that I want to bind User defaults to a table's selected row, I want to bind the value of interface items (a checkbox for example) to the selected row.


Ah, yes, that's easy enough -- just bind the value of the checkbox to the array controller.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2009-09-19 08:08:02 am

robdut
Member
Registered: 2009-09-02
Posts: 301

Re: binding user defaults to a table view selection

Thanks Shane,

It works and I am beginning to understand why. That's a real gift!  Bindings are awesome.

Rob

Offline

 

#6 2009-09-22 10:05:46 pm

robdut
Member
Registered: 2009-09-02
Posts: 301

Re: binding user defaults to a table view selection

Hi Shane,


Shane Stanley wrote:
Ah, yes, that's easy enough -- just bind the value of the checkbox to the array controller.


This is odd. When I tried this before it worked as I wanted; the value of a checkbox was bound to a selection in the table but the table selection retained its name.

Now when I check the checkbox it sets the value of the selected table row to 1 which makes sense perhaps. What I want though is for the value to be bound to the row choice but not the actual value of the selected row.  Maybe this is not possible.

so

Table
SetOne            checkbox checked
SetTwo            checkbox un-checked
SetThree         checkbox checked

not

Table
1                    checkbox checked
SetTwo            checkbox un-checked
1                    checkbox checked

I want to have different sets of user preferences that change as the user selects their set names in the table.

So I bind the checkbox to the array controller for that table and set its

Controller Key  to  selection

Model key Path to properties.title

Baffled,

Rob

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)