Cocoa-Applescript:在GUI中放置GUI

时间:2015-08-06 08:31:57

标签: xcode cocoa user-interface applescript-objc

好的,这是我的第一个Xcode项目,我正在使用Cocoa-applescript为现有的AppleScript创建一个新的应用程序(这是主要的变化)。我读到了我在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,当你按下按钮时,根据按下的按钮,它将'thechoice'设置为“new”,“folder”,“version” “或”设置“,然后脚本的其余部分继续。我已经在Xcode中创建了GUI: [我没有足够的声誉来发布图片,但GUI看起来像这样:

Make New Project
Import to Existing Project
Edit Existing Project

Settings

并将每个按钮链接到处理程序(例如“Make New Project”按钮):

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

每个按钮的类似处理程序。问题是,按下按钮后,它不会继续执行脚本的其余部分 - 它只是停止。所以对于那些知道Cocoa-Applescripts如何工作的人,我真的很感激。

1 个答案:

答案 0 :(得分:0)

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

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