Friday, December 15, 2017

#1 2016-07-18 04:44:05 am

bentoms
Member
Registered: 2008-10-21
Posts: 66
Website

Select Object in Array

Hi folks,

I have an array created with some options:

"Creative & Design",
Digital,
"Project Management",
Test>>,
Unassigned


This is populating fine, & I can get what the user selected.

But, the data in the array will already have a value.. which I have. (For example, "Digital").

What I'm looking to do is to highlight the row which contains the already set data.. Such as the below:

Screenshot%202016-07-18%2010.41.19.png?raw=1

Pointers needed as drawing a blank on how

Offline

 

#2 2016-07-18 10:52:09 pm

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

Re: Select Object in Array

It's impossible to say unless you tell us where and how you're displaying this stuff. And array is just a collection.


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

Offline

 

#3 2016-07-19 03:18:38 am

bentoms
Member
Registered: 2008-10-21
Posts: 66
Website

Re: Select Object in Array

Hi Shane.

The variable 'myChoices' is an AppleScript  list.

Applescript:

-- make list into an array so we can call array methods on it
set theArray to current application's NSArray's arrayWithArray:myChoices
-- set our property to sorted list
set my theData to theArray's sortedArrayUsingSelector:"localizedStandardCompare:"

theArray's contents have a binding to the delegate for the model key theData.

Offline

 

#4 2016-07-19 04:51:04 am

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

Re: Select Object in Array

You're still not answering the question: where you're displaying this stuff. Is it a table? Are you using an array controller?


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

Offline

 

#5 2016-07-19 04:52:04 am

bentoms
Member
Registered: 2008-10-21
Posts: 66
Website

Re: Select Object in Array

Sorry, it's an array controller.

Offline

 

#6 2016-07-19 04:57:02 am

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

Re: Select Object in Array

Try telling the array controller to setSelectedObjects:{"Digital"}


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

Offline

 

#7 2016-07-19 05:38:30 am

bentoms
Member
Registered: 2008-10-21
Posts: 66
Website

Re: Select Object in Array

Brilliant, thanks Shane this worked smile

Applescript:

theArrayController's setSelectedObjects_({myChoices})

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)