0

I am unfamiliar with the subclassing or extending Cocoa framework.
NSButton has a setToolTip method, however NSButtonCell does not. I rather not add new IBOutlets, so how can I accomplish this by accessing NSButton's method?

I have a series of checkboxes, all with NSButtonCell outlets. I am unable to access the setToolTip method but if i were to make an NSButton outlet on the same thing, i do, seems to be where i am stuck.

/* Tooltips require you to connect the NSButton not NSButtonCell */
   [myButton setToolTip:@"This does xyz"];
Jon Weinraub
  • 397
  • 1
  • 8
  • 18
  • 2
    You might want to edit your topic to clarify which one you are asking about, but note that they both have a view, which is what gets the tooltip. – red_menace Nov 25 '20 at 01:56
  • Ohh! `[myButton.controlView setToolTip:@"tool tip"];` seems to have done the trick @red_menace - is this what you meant? – Jon Weinraub Nov 25 '20 at 03:42
  • 1
    Yes, your edit clarified the situation. While `NSButton` inherits from `NSView`, you need to take a sidestep with `NSButtonCell` by getting its `controlView` property in order to get the view for the tooltip. – red_menace Nov 25 '20 at 05:15
  • I would like to accept your comment as the answer, mind answering so you can get the credit? – Jon Weinraub Nov 25 '20 at 05:40

1 Answers1

1

The tooltip in this case comes from NSView. NSButton inherits from NSView, but you need to take a little sidestep with NSButtonCell by using its controlView property to get the view for the cell, for example:

[myButtonCell.controlView setToolTip:@"tool tip"];
red_menace
  • 3,162
  • 2
  • 10
  • 18