2014-06-02 4 views
0

Так что прямо сейчас я создал пользовательский интерфейс на Xcode, и я создаю скрипт AppleScriptObjC.Как программировать радиокнопки в Cocoa Applescript (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_ 

ответ

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 … 

Ваши вопросы довольно общая. Я не могу сказать, какие части процесса вы делаете и чего не знаете. Итак, продолжайте уточнять в комментариях или пересматривать свой вопрос, чтобы мы могли предоставить то, что вам нужно.

+0

В настоящее время я пытаюсь использовать переключатели в викторине, которую я делаю. – James

+0

Затем этот синтаксис должен быть адаптирован к вашим потребностям. Спросите, есть ли у вас какие-либо проблемы. – jweaks

+0

Можете ли вы дать мне более подробную информацию о том, что означает этот сценарий? Я делаю applescript около 6 месяцев и AppleScriptObjC всего за неделю. – James

Смежные вопросы