Hoping someone can point me in the direction of adding a line descriptive text to this nice little progress bar / window. Im still learning about windows and have tried a few options without success including adding
.
-- Created 2015-12-11 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property NSWindowController : a reference to current application's NSWindowController
property NSWindow : a reference to current application's NSWindow
property windisp : false
property aPBar : missing value
property aWin : missing value
set aWidth to 400
set aHeight to 40
set aMaxVal to 100
set aButtonMSG to "Abort"
set aTitle to "Progress..."
--set aWin to makeProgressWindow(aMaxVal, aButtonMSG, aTitle, aWidth, aHeight) of me
set paramObj to {myMax:aMaxVal, myMSG:aButtonMSG, myTitle:aTitle, myWidth:aWidth, myHeight:aHeight}
my performSelectorOnMainThread:"makeProgressWindow:" withObject:(paramObj) waitUntilDone:true
repeat with i from 1 to aMaxVal by 1
if (my windisp) = false then
exit repeat
end if
(aPBar's setDoubleValue:(i as real))
--call main routine here
delay 0.1
end repeat
if i is not equal to aMaxVal then
tell current application
display notification "Aborted"
end tell
end if
my closeWin:aWin
set my aPBar to missing value
set aWin to missing value
on makeProgressWindow:paramObj
set aMaxVal to (myMax of paramObj) as integer
set aButtonMSG to (myMSG of paramObj) as string
set aTitle to (myTitle of paramObj) as string
set aWidth to (myWidth of paramObj) as integer
set aHeight to (myHeight of paramObj) as integer
set (my windisp) to true
--ProgressIndicatorをつくる
set aSlider to makeProgressIndicator(aMaxVal, aWidth) of me
--Buttonをつくる
set bButton to (current application's NSButton's alloc()'s initWithFrame:(current application's NSMakeRect(aWidth / 4, 0, aWidth / 2, 40)))
bButton's setTitle:aButtonMSG
bButton's setButtonType:(current application's NSMomentaryLightButton)
bButton's setBezelStyle:(current application's NSRoundedBezelStyle)
bButton's setTarget:me
bButton's setAction:("clicked:")
set aView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, aWidth, aHeight))
aView's addSubview:aSlider
aView's addSubview:bButton
aView's setNeedsDisplay:true
set (my aWin) to (my makeDockLevelWinWithView(aView, 400, 70, aTitle))
set wController to NSWindowController's alloc()
wController's initWithWindow:aWin
(my aWin)'s makeFirstResponder:aView
wController's showWindow:me
(my aWin)'s makeKeyAndOrderFront:me
end makeProgressWindow:
on clicked:aSender
set (my windisp) to false
end clicked:
--make Window for Display
on makeDockLevelWinWithView(aView, aWinWidth, aWinHeight, aTitle)
set aScreen to current application's NSScreen's mainScreen()
set aFrame to {{0, 0}, {aWinWidth, aWinHeight}}
set aBacking to current application's NSTitledWindowMask
set aDefer to current application's NSBackingStoreBuffered
-- Window
set aWin to current application's NSWindow's alloc()
(aWin's initWithContentRect:aFrame styleMask:aBacking backing:aDefer defer:false screen:aScreen)
aWin's setTitle:aTitle
aWin's setDelegate:me
aWin's setDisplaysWhenScreenProfileChanges:true
aWin's setHasShadow:true
aWin's setIgnoresMouseEvents:false
aWin's setLevel:(current application's NSDockWindowLevel)
aWin's setOpaque:false
aWin's setReleasedWhenClosed:true
aWin's |center|()
aWin's makeKeyAndOrderFront:(me)
aWin's setContentView:aView
return aWin
end makeDockLevelWinWithView
--close win
on closeWin:aWindow
repeat with n from 10 to 1 by -1
(aWindow's setAlphaValue:n / 10)
delay 0.02
end repeat
aWindow's |close|()
end closeWin:
--make progress indicator
on makeProgressIndicator(aMaxNum, aWidth)
set aPBar to current application's NSProgressIndicator's alloc()'s initWithFrame:(current application's NSMakeRect(0, 40, aWidth, 40))
aPBar's setMaxValue:aMaxNum
aPBar's setMinValue:1
aPBar's setIndeterminate:false
aPBar's setControlSize:(current application's NSProgressIndicatorPreferredLargeThickness)
aPBar's setDoubleValue:(1.0 as real)
return aPBar
end makeProgressIndicator