简体   繁体   中英

How to add tooltips to NSButtonCell that is within a NSMatrix

I am currently instantiating an NSMatrix w/ NSButtonCell subclasses through IB

I use the identity inspector to change the Tool Tip property

在此处输入图片说明

But the tooltip doesn't show on the button cell.

If I set a tooltip on the NSMatrix object, a tooltip still doesn't show

If I add an NSButton to the same view, and add a tooltip to that, it does show

Why won't my tooltips on NSMatrix or NSButtonCell show?

I don't know why it can not be set in the Interface Builder (It seems like a long standing issue), but you can set them at least programmatically.

[self.matrix setToolTip:@"Tooltip for first item" forCell:[self.matrix cellAtRow:0 column:0]];
[self.matrix setToolTip:@"Tooltip for second item" forCell:[self.matrix cellAtRow:1 column:0]];

Careful, if in InterfaceBuilder you click the button, you can add the tooltip to the button, and the class displayed under "Custom Class", top right, is NSButton . But, if you click the button again, as you do while selecting stuff in xcode, what is selected is the NSButton Cell , which appears to have a separate tooltip. If you're not careful you add your tooltip to the NSButtonCell instead of the NSButton, and it won't show in your running application.

So, the problem may be that you have clicked the button one more time in IB, and you thought to enter the tooltip for the NSButton, but you didn't.

Personally I think it may be a bug, why would you want to add a tooltip for the button cell?

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