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 に答える