Saturday, September 20, 2014

#1 2013-01-31 10:05:56 am

awado
Member
Registered: 2008-03-20
Posts: 34

Basic question about NSOutlineView configured as source list

Hi!

Is it possible to create such NSOutlineViews - like the Xcode navigator on the left, with clickable list items (buttons?) - purely via ASOC? I found several posts about NSDictionaries and arrays. But none of them was helpful to me with NSOutlineView. Example:

Container A
   Item 1
   Item 2
   Item 3

Container B
   Item 1
   Item 2

Thanks.

Offline

 

#2 2013-01-31 08:26:05 pm

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

Re: Basic question about NSOutlineView configured as source list

awado wrote:

Is it possible to create such NSOutlineViews - like the Xcode navigator on the left, with clickable list items (buttons?) - purely via ASOC?

Yes. The data needs to be a list of records containing sub-records, and then you can use bindings. But setting up the records correctly is reasonably complex.


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

Offline

 

#3 2013-02-01 04:35:27 pm

awado
Member
Registered: 2008-03-20
Posts: 34

Re: Basic question about NSOutlineView configured as source list

Are these records part of an NSDictionary construct? I tried to bind one but I had no success, not sure if the dict had the right structure. So I'm looking for some sample code.

Offline

 

#4 2013-02-01 04:53:20 pm

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

Re: Basic question about NSOutlineView configured as source list

awado wrote:

Are these records part of an NSDictionary construct?

An AS record becomes an NSDictionary when passed to a Cocoa method, so you can sort of use the terms interchangeably in that respect.

I tried to bind one but I had no success, not sure if the dict had the right structure. So I'm looking for some sample code.

I'm pretty sure someone posted an example of code for an NSOutlineView in this forum a while back, so a search should help you.


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

Offline

 

#5 2013-02-02 03:10:22 pm

awado
Member
Registered: 2008-03-20
Posts: 34

Re: Basic question about NSOutlineView configured as source list

Now I can successfully load a plist into such NSOutlineView. But I get only blank entries with no text. I can collapse and click them. Is there something that has di be set in IB to make them appear or needs the plist some additional entries or a different structure? My plist:


   <!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
    <plist version='1.0'>   
        <array>
            <dict>
                <key>children</key>
                <array>
                    <dict>
                        <key>child</key>
                        <string>test1</string>
                    </dict>
                    <dict>
                        <key>child</key>
                        <string>test2</string>
                    </dict>
                    <dict>
                        <key>chidl</key>
                        <string>test3</string>
                    </dict>
                </array>
             </dict>
        </array>
    </plist>

P.S.: Checked the tutorial "ApplescriptObjectC Part 4" http://macscripter.net/viewtopic.php?id=30359 and it's the same there. Seems to be related to some changes in Xcode since then?

Last edited by awado (2013-02-02 04:49:13 pm)

Offline

 

#6 2013-02-02 06:30:32 pm

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

Re: Basic question about NSOutlineView configured as source list

it sounds like a bindings problem. And that example you refer to is for a table view, not an outline view -- it makes a lot of difference.


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

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.031 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)