Wednesday, May 23, 2018

#1 2018-05-17 03:52:27 pm

jcwelch
Member
Registered: 2009-09-11
Posts: 13

Records and popupbuttons

Okay, so I have a popup button populated from a list of records. Say, {{name:bill,eyes:green,feet:two},{name:john,eyes:blue,feet:yes}}

I've set up my array controller and popup bindings correctly so the popup list shows the correct values, (in this example, name).

What I'd like to get returned when the user makes a selection though, is the entire record, so if they pick "john", I get the entire thing.

Offline

 

#2 2018-05-17 05:34:56 pm

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

Re: Records and popupbuttons

Try binding to the Selected Object.


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

Offline

 

#3 2018-05-17 06:46:01 pm

jcwelch
Member
Registered: 2009-09-11
Posts: 13

Re: Records and popupbuttons

so I created a test variable:

property popupTest:""

I bind popupTest to selected object, binding it to delegate and popupTest in the model key path, changing nothing else. All I get is the value I see in the popup.

Offline

 

#4 2018-05-17 07:49:41 pm

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

Re: Records and popupbuttons

You're not saying where you want to "get" the value. If you have an action handler connected to the popup, you can get it like this:

Applescript:

   on chooseItem:sender
       set x to arrayController's selectedObjects()'s firstObject()
       current application's NSLog("selected: %@", x)
   end chooseItem:

where arrayController is an outlet to your array controller.


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

Offline

 

#5 2018-05-17 10:49:10 pm

jcwelch
Member
Registered: 2009-09-11
Posts: 13

Re: Records and popupbuttons

I'm trying to get the values when they make a selection in the popup.

I have the ArrayController's content array bound to the list of records.
The popup's content values are connected to the name value in the record, and selected object is bound to the variable that i'm trying to inject the record values into.

so, because I want to get the concepts correctly, I should be binding that variable I want the record to be injected into to the array controller?

Offline

 

#6 2018-05-18 03:57:35 am

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

Re: Records and popupbuttons

Don't try to do everything with bindings. For the selection, IMO you're better of using an action handler. That way you get the value plus an indication that the selection has changed.


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

Offline

 

#7 2018-05-18 12:59:08 pm

jcwelch
Member
Registered: 2009-09-11
Posts: 13

Re: Records and popupbuttons

that did it (once I used selectedObjects()'s instead of selectedObject()'s)!

Thanks man!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)