Hi!
in an ASS application i have a level indicator.
In Interface Builder I can set a warning value and a critical value, which changes the color of the indicator from green to orange to red, if the value is lower.
How can I change the warning value and critical vale during runtime?
Or can I otherwise change the color of a level indicator?
to set critical and warning values during runtime there is no AppleScript access - you have to use 'call method’s for this. Without having tried I’d say something like this should work:
call method “setWarningValue:” ofyour Level Indicatorwith parametervalue you want to set call method “setCriticalValue:” ofyour Level Indicatorwith parametervalue you want to set
an ‘update’ might be necessary to show the changes.
Unfortunately the class has no method for changing/setting it’s colors. If you want this you’d have to this in a custom subclass of NSLevelIndicator.
I just tried it - updating the view isn’t necessary to have the changes displayed. Here’s what I tried - it works regardlessly here:
tell control "speedRuler" of window "main"
set contents to 89
delay 1
call method "setWarningValue:" of it with parameter 80
delay 1
call method "setCriticalValue:" of it with parameter 85
delay 1
set contents to 84
delay 1
set contents to 73
end tell
Thank you Dominik.
It works fine, as well as my first try
set temp to control "speedRuler" of window "main"
call method "setWarningValue:" of temp with parameter 80
works.
My problem was, that I duplicated a TestButton in InterfaceBuilder, and just gave it a name. I did not notice, that duplicating an object DOES NOT duplicate its EventHandlers and ScriptConnections. (Boy, i consider this to be a severe bug). So my TestButton2 did just nothing at all.