This code is made in Xcode and it use AppleScript AppDelegate Template.
It demostrate the difference between IBAction and IBOutlet with an slider.
In short the slider send a action to property handler. The property handler get the intValue.
We make a connection between the slider and AppDelegate by picking the property handler.
We have the intValue now we need to make reference in Interface Builder IBOutlet by
making a connection from text field and choose Referencing Outlet to App Delegate.
buttonAction is only to check/debug a value or anything.
Ps. You need Xcode to follow this guide.
--
-- AppDelegate.applescript
-- Dialog
--
--
-- Xcode: Make a label, slider, text field and button
-- mark button -> right click -> drag sent action to App Delegate -> buttonAction
-- mark slider cell -> right click -> drag sent action to App Delegate -> sliderAction
-- mark text field cell -> right click -> drag Referencing Outlets to App Delegate
--
script AppDelegate
property parent : class "NSObject"
-- IBOutlets
property theWindow : missing value
property sliderValue : missing value
property theNumber : missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on sliderAction:sender
set theNumber to sender's intValue()
sliderValue's setStringValue:theNumber
end sliderAction:
on buttonAction:sender
display alert "Slider 1: " & (its theNumber)
end buttonAction:
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script