0

所以现在我已经在 Xcode 上构建了一个用户界面,并且正在编写 AppleScriptObjC 脚本。

我的界面上有 4 个单选按钮。我如何对它们进行编程?这是我当前的代码:

-- IBOutlets
property window : missing value
property question1Radio1 : missing value
property question1Radio2 : missing value
property question1Radio3 : missing value
property question1Radio4 : missing value
property enterButton : missing value

on applicationWillFinishLaunching_(aNotification)
    -- Insert code here to initialize your application before any files are opened 
end applicationWillFinishLaunching_

--Radio button script here

on applicationShouldTerminate_(sender)
    -- Insert code here to do any housekeeping before your application quits 
    return current application's NSTerminateNow
end applicationShouldTerminate_

这是我刚刚尝试但不起作用的代码

    -- IBOutlets
property window : missing value
property question1Radio1 : missing value
property question1Radio2 : missing value
property question1Radio3 : missing value
property question1Radio4 : missing value
property enterButton : missing value

on applicationWillFinishLaunching_(aNotification)
    -- Insert code here to initialize your application before any files are opened 
end applicationWillFinishLaunching_

on buttonClicked_(sender)

    if question1Radio1 = false as boolean then display alert "Works"

end buttonClicked_

on applicationShouldTerminate_(sender)
    -- Insert code here to do any housekeeping before your application quits

    return current application's NSTerminateNow
end applicationShouldTerminate_
4

1 回答 1

0

我建议只对整个矩阵使用插座,而不是 4 个单独的按钮。然后,您可以连接矩阵,并在按钮(或矩阵,如果你喜欢)的发送动作中,获取矩阵的索引以对其进行操作。如:

on buttonWasClicked_(sender)        
    set theCol to (questionMatrix's selectedColumn()) as integer
    set theRow to (questionMatrix's selectedRow()) as integer

    if {theCol, theRow} is {0,0} then 
    -- do stuff
    else if …

你的问题很笼统。我不知道你在这个过程中做了哪些部分,不知道。因此,请继续在评论中澄清或修改您的问题,以便我们提供您需要的内容。

于 2014-06-02T15:32:11.980 回答