【问题标题】:Cocoa-Applescript: Placing a GUI in an applescriptCocoa-Applescript:在 applescript 中放置 GUI
【发布时间】:2016-04-05 10:40:02
【问题描述】:

好的,这是我的第一个 Xcode 项目,我正在从现有的 applescript 制作一个新的应用程序,使用 Cocoa-applescript 为它制作一个 GUI(这是主要的变化)。我阅读了所有我能找到的关于 cocoa applescript 中的 GUI,我想把它转换一下:

choose from list baseactions with title "Version Control" default items defaultaction with prompt "What do you want to do?" OK button name "Go" cancel button name "Quit"
set choice1 to result as string
if choice1 = false then
    error number -128
else if choice1 = "Make New Project" then
    set thechoice to "new"
else if choice1 = "Edit Existing Project" then
    set choice2 to button returned of (display dialog "What would you like to do with the existing Project?" buttons {"Quit", "Make new version", "Create Project Folder"} default button 3 with title "Version Control" with icon "Icon.png")
    if choice2 = "Quit" then
       error number -128
    else if choice2 = "Create Project Folder" then
       set thechoice to "folder"
    else if choice2 = "Make new version" then
       set thechoice to "version"
    end if
else if choice1 = "Change Settings" then
    set thechoice to "settings"
end if

到一个 GUI,它不是多个对话框,而是一个流畅的 GUI,当您按下按钮时,根据按下的按钮,它将“选择”设置为“新”、“文件夹”、“版本” " 或 "设置" 然后脚本的其余部分继续。我已经在 Xcode 中制作了 GUI: [我没有足够的声望来发布图片,但 GUI 看起来像这样:

Make New Project
Import to Existing Project
Edit Existing Project

Settings

并将每个按钮链接到一个处理程序(例如“创建新项目”按钮):

on NewProject_(sender)
    set thechoice to "new"
end

每个按钮都有类似的处理程序。问题是,在我按下按钮后,它不会继续执行脚本的其余部分 - 它只是停止。因此,对于任何知道 Cocoa-Applescripts 如何工作的人,我将不胜感激。

【问题讨论】:

    标签: xcode cocoa user-interface applescript-objc


    【解决方案1】:

    有关 ASOC 的初学者介绍,请在此处观看“介绍视频”: http://www.macosxautomation.com/applescript/develop/index.html 或去这里: http://asobjcresources.weebly.com

    或者阅读 Shane Stanley 的优秀书籍“AppleScriptObjC Explored”,您可以在上面列出的介绍视频框下在线购买。

    【讨论】:

    • 这两个都是很好的起点,问这个问题促使我学习了 Cocoa-applescript 的基础知识,这两个网站非常适合初学者
    猜你喜欢
    • 2011-07-14
    • 2013-11-28
    • 2013-05-07
    • 1970-01-01
    • 2010-11-02
    • 2014-07-19
    • 1970-01-01
    • 1970-01-01
    • 2013-01-14
    相关资源
    最近更新 更多