Cocoa Application - Tooltip

ronenmagid1 used Ask the Experts™
On my Mac/Cocoa I'm programmatically displaying a bitmap - projecting it using using "drawInRect" onto one of my NSView instances.

I'd like this bitmap to have a tooltip.

As I'm new to Mac programming, I'd appreciate any pointer you may have.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can find the info about the tooltips in Mac OS Reference Library:

Mainly, NSView contains few methods to work with the tooltips. setToolTip, addToolTipRect, removeAllToolTips, ... . NSWindow also has methods managing the tooltips:

Actually, almost all in the GUI part is derived from NSView and so almost everything supports the tooltip. It is very simple to assign a tooltip for a button. You can do it in the interface builder - in the identity inspector set the text you want to see. I attached few screenshots.

You will find a nice explanation and code here:



pgnatyuk: my bitmap is not a control, it's an arbitrary area on my view. Would this make creating a tooltip for this rectangle more complicated?

I do not see your code. If it is about Cocoa (you make Mac OS application), and if you have only the window (NSWindow), I think, you need to make a custom view (NSView). NSView knows how to work with the tooltips. You will set all parameters and it will work. It is a bit late here to test right now. For any control, as you see, it is a trivial task to add a tooltip.

Have you read this article?


Try this code:
[myView setToolTip:@"This is a test view"];

I didn't test it.

I took it from here:


Thanks. That did it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial