Thursday, December 14, 2017

#1 2009-10-06 06:34:20 pm

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

Displaying sheets

A couple of people have asked about displaying sheets. Unfortunately they can't be handled fully in ASObjC as it stands -- some Objective-C code is required.

I've written a step-by-step guide to what's required, along with a sample project that includes code for showing all kinds of sheets: alerts, save panels, open panels, and custom sheets. You can download it from here:

http://www.scriptingmatters.com/ASObjC

Any feedback is welcome.


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

Offline

 

#2 2009-10-07 07:58:08 am

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

Re: Displaying sheets

That's Great Shane.
So far it works with Open Panel in my app. The Open Panel though isn't working as expected:

Applescript:

on showOpenPanel_()
       set thePanel to current application's class "NSOpenPanel"'s openPanel()
       set my contextInfo to "Open"
       tell thePanel
           setMessage_("Choose file:")
           setExtensionHidden_(true)
           setShowsHiddenFiles_(true)
           setTreatsFilePackagesAsDirectories_(true)
           setCanChooseFiles_(true)
           setCanChooseDirectories_(true)
           setAllowsMultipleSelection_(true)
           setResolvesAliases_(true)
           -- The following method is deprecated in 10.6, but the alternative is inaccessible from ASObjC
       beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo_(missing value, missing value, {"txt"}, mainWindow, me, "sheetDidEnd:returnCode:contextInfo:", missing value)
       end tell

end showOpenPanel_

It won't show files Just directories. I changed the options around several times but still no files showing in the panel. maybe I am missing something. Or is this what they mean by deprecated? And if there is no ASOC way with the deprecated method, can we run the new method from OBJ-C side?

I think we need this fixed by Chris Nebel and friends. In the end we really should be able to access these basic methods from the script if ASOC is to be a first class citizen, though I do enjoy your elegant workarounds. Without you and Craig we would be quite lost!

Thanks,  Rob

Offline

 

#3 2009-10-07 05:22:43 pm

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

Re: Displaying sheets

Do you mean no files appear, or they just appear grayed out?


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

Offline

 

#4 2009-10-07 06:08:00 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: Displaying sheets

Try setting the show directories to false and then try multiple false and then both...

Offline

 

#5 2009-10-07 06:35:03 pm

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

Re: Displaying sheets

Are you sure there are .txt files in the directory?


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

Offline

 

#6 2009-10-07 07:20:04 pm

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

Re: Displaying sheets

Hi Shane,

Doh!

I just pasted your Open Panel handler in there and didn't notice the "txt" so I set it to missing value (?) and it shows everything now.

Sorry- my mistake.

Rob

Offline

 

#7 2009-10-07 07:27:00 pm

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

Re: Displaying sheets

I should have explained that part, sorry.


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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)