i just wrote a script app, and would like to use a cocoa interface using as studio, but i cant find any online reading material (except for apple’s document, which is not so friendly) all i managed to do so far was make a button that beeped when clicked, but it got all messed up when i added another button, where can i find a simple tutorial?
this is so weird!
how do i make different buttons do different actions? when i check the “clicked” option in the info for the buttons it adds this to the script
on clicked theObject
(*Add your script here.*)
end clicked
and it does the actions for all buttons returned! is there something i’m missing???
Try something like this, LobsterMan:
on clicked btn
set btnName to btn's name
if btnName is "something" then
doSomething()
else if btnName is "somethingElse" then
doSomethingElse()
-- and so on...
end if
end clicked
thanks, its worked!
you cna also do:
on clicked theObject
if the name of theObject = "nameofbutton" then
--do something
else if the name of theObject = "nameofotherbutton" then
--do something else
end if
end clicked
I have a similar question, but it involves clicking the Close Window. I want the script to quit when I close the window. There doesn’t seem to be any documentation on how to assign an action to these buttons.
There is a “will close” or “should close” action which you can apply to any window!
Just
¢ select the window
¢ open the inspector and select “Applescript”
¢ at the bottom of the list you will find a n item called “window”
¢ there you find the actions for window changements
Hope this helped
Vince
You want the application to quit when you close the window?
Open the inspector in Interface Builder (Tools>Inspector or Shift+Apple+I), click on “Files Owner” on the MainMenu.nib window, click on the Applescript pane in the inspector, and under “Application” should have “should quit after last window closed” check that, then check your script in the box below that, then save your nib.
in your script put
on should quit after last window closed theObject
return true
end should quit after last window closed
Yes, I want the application to quit when I close the last window.
I made the two changes you suggested in the nib in IB and in the Applescript as follows:
on clicked theObject
if title of theObject is “English 5*” then
tell application “QuarkXPress”
tell document 1
show layer named “Color”
show layer named “5 Star”
hide layer named “Spanish 5 star disclaimer”
show layer named “English 5 star disclaimer”
end tell
tell application "Finder"
display dialog "English 5-Star completed"
end tell
tell application "QuarkXPress"
activate
end tell
end tell
end if
end clicked
on should quit after last window closed theObject
return true
end should quit after last window closed
It does not quit the application. What am I doing wrong?