I have a NSTableView
with a NSImageCell
in it. I would like to add a tooltip that when I hover the image with the mouse i get a tooltip with the Path of the image. What is the best way to do this?
the problems I have are these:
- retrive the path of the hovered image
- display it in the tooltip
please keep your answers easy, I am a newbie.
---EDIT---
additional info: myarray.arrangedobjects is what fills the table. it is an array of NSMutableDictionaries. the dictionary has following Keys:
- image (the one displayed in the table that i would like to place the tooltip over)
- imagepath (the text i would like to display in the tooltip)
- filename (is displayed in another cell)
You will need to provide a delegate for the
NSTableView
and implement this delegate method:You can find the docs for the
NSTableViewDelegate
protocol here. You need to make sure to plug the delegate into the delegate outlet on theNSTableView
using IB. Your method will not be called unless that has been done. Also, it's worth noting that this delegate method is called on demand, not up-front, so it wont get called until you've parked your mouse hovering over a cell. This approach should work for both tables with a data source and tables that use bindings.I put a trivial example up on GitHub.