Ok, I have used interface builder and added tooltips to all controls.
I would like to offer the user a menu item "disable tooltips".
How do I disable all tooltips globally on a cocoa application?
Ok, I have used interface builder and added tooltips to all controls.
I would like to offer the user a menu item "disable tooltips".
How do I disable all tooltips globally on a cocoa application?
Instead of setting the text for the tooltips in directly in Interface Builder, make NSString properties for them in your view controller (or other bindable object). Use a Boolean property to control whether or not the tooltips will be shown.
@interface YourViewController : NSViewController
@property (readonly) NSString *thisTooltip;
@property (readonly) NSString *thatTooltip;
@property BOOL showTooltips;
@end
@implementation YourViewController
- (NSString *)thisTooltip {
if (showTooltips) {
return @"This is a tooltip";
}
else return @"";
}
- (NSString *)thatTooltip {
if (showTooltips) {
return @"That is a tooltip";
}
else return @"";
}
@end
Use the Bindings Inspector in IB to bind the Tooltip to the Property:
As you can see, this strategy makes it possible to customize your tooltips dynamically, while your application is running.