How do i do so that when i click a button, an alert message comes up "Are you sure you want to x"
Yes No
Yes No
Study the NSAlert Class
Not really a helpful answer, i knew that already.
Did you also look at the sample code associated with NSAlert?
Here's the NSAlert online class reference page:
https://developer.apple.com/library...lasses/NSAlert_Class/Reference/Reference.html
Several samples are linked under "Related sample code".
If you've looked at the NSAlert class, and studied its sample code, then please restate a more specific question.
Not really a helpful answer, i knew that already.
Do you want to be pointed to the right direction or someone to hand you the code?
Doesn't really matter
Yes i have, the specific question is.
Let's say i have a button, and when i click it i get an alert box. I need to click "OK" for the script to run ( I have an applescript on the button).
If it doesn't really matter, I've pointed you to the right direction and Chown33 went even further providing you the class reference page so you don't even need to google it!
But I won't do your work for you and hand you the code, sorry
If you dont want to help why do you even bother posting in this help thread?
If you dont want to help why do you even bother posting in this help thread?
As you don't seem to be accepting of the help that's offered - why did you even bother asking your question?
Just my worthless opinion - Much of the value in any programming language is wasted - if you choose not to learn how to program.
Rather than have someone more experienced than you throw you a bone (that may or may not be useful to you) - how about showing what code you have tried so far - and is not working for you. I'm sure that someone will offer a way to correct it... or, link you to references for you to "learn" something.
You have been helped by several people in this thread. You've now been nothing but rude and disrespectful to those very people that helped you.
Why did i ask the question? Because i wanted to know the answer? I dont see how to know what to type because it only explains what commands do, and I'm trying to learn it. I have tried this so far
But i dont know how to connect so that the OK button runs the other script script.Code:on mybuttonhandler127_(sender) "display alert "Warning" message "Are you sure?". end
Why did i ask the question? Because i wanted to know the answer? I dont see how to know what to type because it only explains what commands do, and I'm trying to learn it. I have tried this so far "display alert "Warning" message "Are you sure?". But i dont know how to connect so that the OK button runs the script....
I dont see how anyone has helped me, i already knew what NSAlert was and someone said that i should look that up, i said that i already knew that, then I'm disrespectful? Its like asking, "how do i upgrade to Mavericks?" And then someone answers "Download it from the App Store, and figure the rest out yourself".
When asking a question, it's important to specify the language you're using.
You didn't say "in AppleScript", so people reasonably assumed Objective-C.
I'm not entirely sure you're asking for AppleScript, because the posted code isn't syntactically correct for AppleScript.
So let me ask this:
Exactly what language are you working in?
Im working in AppleScript, i have tried that code in Xcode and it works, whats wrong with it?
on mybuttonhandler127_(sender)
"display alert "Warning" message "Are you sure?".
end
If you dont want to help why do you even bother posting in this help thread?
We gave you the manual. Now what you're asking is to someone read it for you.
This is what you posted:
As posted, you have an unmatched " before the display alert, and a period ('.') at the end of that line.Code:on mybuttonhandler127_(sender) "display alert "Warning" message "Are you sure?". end
Typical macrumors, is there any forum where people just pick on you?, i didn't see how to do it?
Consider yourself lucky that this isn't StackOverflow, or your topic would have been closed or down voted into oblivion already.
No one can see your computer or read your mind to know what you are doing (well, I hope not, anyway) so you need to explain it in excruciating detail. No one knows what kind of programing experience you have either, so you also need to explain that.
So here we are, a few days and a dozen or so replies later, and now there are enough bread crumbs to know that you are using AppleScript in Xcode (I can understand some reluctance to mention the AppleScript part, since Objective-C programmers usually run away screaming when you do that). Most regular AppleScript commands such as display alert work the same in an AppleScriptObjC project, so in your action handler you just need to get the button that was pressed in the usual way, and if it is the button you are looking for, then run your other script or handler in the usual way. Using an NSAlert works more or less the same, you will just be using various class methods to manually create and display the alert instead of having everything done for you by the display alert command.
If you don't know how to do either of those, again, you will need to explain that, or exactly what isn't working.
onmybuttonhandler_(sender)
tell application "Finder" restart
end
display alert "Warning" Message "Are you sure?"
tell application "Finder" restart
end
on myButtonHandler_(sender)
display alert "Warning" message "Are you sure?" buttons {"Yes", "No"}
if button returned of the result is "Yes" then
tell application "Finder" to restart
# whatever
end if
end myButtonHandler_
The solution is to just group your various statements together:
Code:on myButtonHandler_(sender) display alert "Warning" message "Are you sure?" buttons {"Yes", "No"} if button returned of the result is "Yes" then tell application "Finder" to restart # whatever end if end myButtonHandler_