如果声明,xcode 4 applescript单选按钮

时间:2012-12-03 15:20:40

标签: xcode macos xcode4 applescript

我创建了应用程序(Cocoa-AppleScript Application),它使用用户提供的文本字段和“安装”按钮的值执行shell命令。我希望增加应用程序以合并允许用户选择一个或多个单选按钮的单选按钮(列表),并在单击安装按钮时,将执行每个单选按钮的相关命令。我在网上找不到与收音机按钮和if语句有关的信息。

我确实找到了这篇文章,但它似乎不适用于xcode 4: http://macscripter.net/viewtopic.php?id=24755

  on InstallButton_(sender)
    set hostName to ""
    set hostName to textField's stringValue as string
    do shell script ("/usr/sbin/scutil --set HostName " & hostName) with administrator privileges
    do shell script ("/usr/sbin/scutil --set ComputerName " & hostName) with administrator privileges
   #IF RADIO BUTTON 1 IS SELECTED
         RUN COMMAND1
   #IF RADIO BUTTON 2 IS SELECTED
         RUN COMMAND2
end InstallButton_

1 个答案:

答案 0 :(得分:1)

我无法使用单选按钮(列表)找到解决方案,但我能够找到如何使用复选框获得确切结果。属性checkBox:

missing value set checkBoxValue to "" 
set checkBoxValue to checkBox's integerValue as string 
#display dialog checkBoxValue 
if checkBoxValue = 1 
#run policy 
end 

如果选中该复选框,则checkBoxValue参数= 1,如果未选中,则该值为0.