views:

109

answers:

2

I'm trying to enable or disable all the control in a window as the programme changes from interactive to non-interactive mode. How can I ask a window to give me all its contents?

every control of window "mainWindow"

doesn't work, nor does

contents of window "mainWindow"

Actually, I haven't been able to find any good documentation for interacting with menu items from interface builder at all. Things like how to set the contents of popups, and buttons and so on.

thanks

The way I do it at the moment is:

property onlineControls: {"maxLength", "speed", "accelerationSlider", "accelerationField", "showInfo"} --and so on, listing all the controls by name

on enableControls(theList, enableState)
    tell window "mainWindow"
        repeat with theControl in theList
            set the enabled of control theControl to enableState
        end repeat
    end tell

enableControls(onlineControls, true)

I've made several lists of controls tht get turned on or off depending on the state the programme is in. But it has to be hard coded, which I don't see as being the best way.

A: 

I haven't been able to find a way to get all the controls in a window, but here's an example of interacting with the menu of a popup button:

tell menu of popup button "somePopupButton" of window "mainWindow"
    delete every menu item
    repeat with i in someItems
        make new menu item at end of menu items ¬
            with properties {title:i, enabled:true}
    end repeat
end tell
Isaac
Thanks. Unfortunately I want to make the popup buttons (and the buttons, and sliders and text fields etc) disabled, not the menu items within them.
stib
+1  A: 
tell application "System Events"
    tell process "Adium"
        get entire contents of window 1
    end tell
end tell

This script will give you as result all contents of front window of Adium: butons of window, tool bars of window, buttons of tool bars, etc. Enjoy =]

BoB1990
"entire contents" Whoda thunk it? Thanks for that.
stib

related questions