Search code examples
xcodeapplescript-objc

How do you know that a checkbox is selected to perform a function


I would like to know how can I identify that a checkbox is selected and then do something. for example: I select the checkbox enter image description here

"Google" and then I click on the button "Go" then the app opens to the page of Google.

Apologize advance if has not learned how to express myself.


Solution

  • Assuming you are talking about an AppleScriptObjC application declare two properties

    property googleCheckbox : missing value
    property appleCheckbox : missing value
    

    In Interface Builder connect the outlets of both checkboxes to their properties

    Then get the state of a checkbox with

    set googleState to googleCheckbox's state() as integer // 0 is off, 1 is on
    

    Alternatively declare two boolean properties instead

    property googleState : false
    property appleState : false
    

    and bind the value of a checkbox to the property. Then you can get the value directly.