我正在运行一个AppleScript程序,我要求用户输入他们的名字。如果用户单击"确定",则名称将存储到我想要的变量中。但是,如果用户单击"取消",则程序退出。如何将其设置为隐藏"取消"按钮,所以它不是一个选项来点击,或设置一个循环,以便如果点击取消,它只是继续询问用户他/她的名字,直到它被输入?
提前致谢。
i
答案 0 :(得分:0)
简单的解决方案
display dialog "Please Enter Your Name." default answer " " with title "Enter Name" buttons {"OK"} default button 1
答案 1 :(得分:0)
这是我得到的:
display dialog "Please Enter Your Name." default answer "" buttons {"Submit"} with title "Enter Name" default button 1
if the button returned of the result is "Submit" then
set yourVariable to text returned of the result
end if
答案 2 :(得分:0)
隐藏取消按钮的方式如下:
display dialog "Please Enter Your Name." default answer " " buttons {"ok"} with title "Enter Name"
set a to the text returned of the result
但是如果你想要重复然后使用它(我已经做了所以他们必须输入一些东西而不是按下ok结束它:
repeat
display dialog "Please Enter Your Name." default answer "" buttons {"ok", "cancel"} default button 1 with title "Enter Name"
set a to the text returned of the result
if the button returned of a is "ok" then
if the text returned of a ≠ "" then
exit repeat
end if
end if
end repeat