Now EL Capitan is installed on my MacPro, I need to update some scripts using 24U Appearance osax to display progress bar.
Is it possible to use NSProgress from a script bundle?
Do we need to draw a window before?
Or can we add an instance of NSProgress as an accessory view in the enhanced alert library?
All I’m able to do with NSProgress is:
use framework "Foundation"
use scripting additions
set aProgress to current application's NSProgress's progressWithTotalUnitCount:10
tell aProgress
its setCompletedUnitCount:1
its setLocalizedDescription:"Main description"
its setLocalizedAdditionalDescription:"Additional Description"
end tell
I have 2 problems with the builtin progress support:
In case of a script bundle, it wont display (like it does with Apple’s Script Menu) if the script is triggered from FastScript’s menu.
With an applet, each time you activate an application, the applet goes background.
The only way I found to force the progress window to stay at foreground is to slice my scripts in (too many) parts.
I haven’t tried it, but I think maybe you’re expecting more of NSProgress than there is. All it really provides is a mechanism where disparate bits of code can communicate with it easily – you still ahve to provide the window and all its elements.
I know Stefan Klieme’s work since its first release.
Each time I gave it a try, it ends with the deletion of the file.
I’m not saying it’s a bad work. It only does not fit my needs.
For now, the Applescript built-in Progress Bar with some activate me statements at the right place will do the trick.
Finally, I found how to built a window and put a NSProgressIndicator in it.
In my peregrinations on Apple’s API Reference site, I saw the NSProgressIndicatorThickness constant but didn’t find how to use it along with preferredLargeThickness parameter.
Can someone give me an example of the right method?
Thanks.
If you use the new versions, your script won’t run under old versions of the OS. This isn’t a problem with Objective-C because the values are resolved at compile time, whereas AppleScript resolves them at run time.
This is where using Script Debugger’s Use Properties for Cocoa Terms comes in handy. With it on, and using code-completion, I get this:
-- classes, constants, and enums used
property NSControlSizeRegular : a reference to 0
theIndicator's setControlSize:NSControlSizeRegular
Because the script defines the enum’s value itself, it will run under any version without problems.
There are several AppKit enums where this sort of renaming has happened (it’s to do with aligning them more with Swift’s naming style).