Tooltips Question

Hi All,
I’d like to add tooltips to my project, but I’d like to allow the users to turn them on or off. In applescript studio I had to individually toggle the tooltips text for each gui element from “” to whatever the tip was in the code. I was hoping that there would be something less tedious to code in ASOC, but I can’t find anything in the documentation that seems to do that. I see in interface builder that there is a section for adding tooltip text, via the setToolTip method, but is there some way of toggling them all on/off once they’ve been set in IB? It looks like the only other alternative is to use bindings and then set the text in code, but it sure would be nice to be able to do this all in interface builder. Thanks in advance for any help.

The only way I know of is to create an applescript class that sets up all the tooltips with the setToolTip: method, and when you want to get rid of them you simply call removeAllToolTips.

Check in the NSView Class Reference in the docs for more details, there is a section on tooltips in the Tasks.

I didn’t see any binding trick that can be done in IB, although I could be wrong, and would like to be proven so! :wink:

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

You could probably do it via bindings. Try setting all your toolips in a record: {tip1:“Blah”,tip2:“Blah”…}, with another having blank strings. Then bind the items’s tooltips to a model key path of theVar.tip1, etc. To toggle, you’d set theVar to one of the records.

Thanks for the tips and ideas. I’d seen the setToolTip and the removeAllToolTips methods, but I couldn’t find anything like a restoreAllToolsTips method that would turn them back on at once, instead of having to turn each back on individually. I guess I’ll go the bindings way, but for academic purposes, would something like the following be possible? First enter the tooltip text in the identity tab of the inspector in interface builder for each gui object that I want to have a tooltip. For my brain, this just works better, than entering the tips in code, assigned to some variable that is then bound to a gui object. Then somehow determine which objects have tooltips and what they are, so that info can be stored in an array and used to turn the tooltips back on. There is a toolTip method to get the tooltip of an object, but is their some way of testing every object in an application? Or am I going off on a wild goose chase? :slight_smile: