1

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?

Duck
  • 34,902
  • 47
  • 248
  • 470
  • Have a look at: [link](http://www.componentix.com/blog/20/change-tooltip-display-delay-in-cocoa-application) – Heinrich Giesen Mar 16 '15 at 07:17
  • this answer is almost perfect but there is one problem: the application will just read the written value the next time it starts. – Duck Mar 16 '15 at 09:57

1 Answers1

1

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:

enter image description here

As you can see, this strategy makes it possible to customize your tooltips dynamically, while your application is running.

ElmerCat
  • 3,126
  • 1
  • 26
  • 34