【问题标题】:xcode 4 applescript radio button if statementsxcode 4 applescript 单选按钮 if 语句
【发布时间】:2012-11-21 02:16:21
【问题描述】:

我创建了应用程序(Cocoa-AppleScript 应用程序),该应用程序使用用户提供的文本字段的值和“安装”按钮执行 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_

【问题讨论】:

  • 我对上述请求进行了广泛的搜索,但发现与手头问题相关的材料有限。
  • 我找到了以下文章,但它似乎与 xcode 4 不兼容。macscripter.net/viewtopic.php?id=24755>
  • 我无法使用单选按钮(列表)找到解决方案,但我能够找到如何使用复选框获得确切结果。 property checkBox : missing value set checkBoxValue to "" set checkBoxValue to checkBox's integerValue as string #display dialog checkBoxValue if checkBoxValue = 1 #run policy end if checkBoxValue checkBoxValue parameter = 1 if it is not check the value is 0.

标签: xcode macos xcode4 applescript


【解决方案1】:

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

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。

【讨论】:

    猜你喜欢
    • 2012-11-21
    • 2013-07-21
    • 1970-01-01
    • 2016-08-04
    • 2014-05-31
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多