Hello everyone,
I’m transitioning some scripts I have written from AppleScript to AppleScriptObjC and I’m having trouble working with showing/hiding windows.
One of the scripts I’m trying to move over is really long and I’m replacing a few of the dialogs with more complex windows created in IB however I’m having trouble. Basically I need to click a button on one window (mainWindow) that will trigger a new window to show (or a dialog) and the mainWindow should hide and another function should be called. I can get this to work by connecting the window to the button in the IB and the orderOut but this doesn’t run my code, it just hides the window. I also managed a function to be called when the button is clicked and show a dialog programmatically but not a window, and cannot hide the main window.
The error I get is:
[AppDelegate displayButton:]: missing value doesn’t understand the “orderOut_” message. (error -1708)
The example below (if it worked) would help me understand how it works and the syntax used however I haven’t managed to make it work.
use Framework "Foundation"
use scripting additions
script AppDelegate
property parent : class "NSObject"
property mainWindow : missing value
property isShowing : 0
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
on displayButton_(sender)
if (isShowing = 0) then
set isShowing to 1
mainWindow's orderFront:sender
else
set isShowing to 0
mainWindow's orderOut:sender
end
end displayButton_
end script
Can anyone point me in the right direction?
Shane already told me that the syntax to orderOut is orderOut:sender instead of orderOut_(sender)