简体   繁体   中英

How do I extend NSButtonCell with a method in NSButton?

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"];

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"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM