Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I highlight the cells of a IKImageBrowserView on mouse over?

I would like to provide some feedback when the mouse is over on one of the cells of an IKImageBrowserView.

Specifically, I'd like to resize the cell a little, to make it appear slightly larger on mouse-over. Alternatively, highlighting the background/border would be fine.

Unfortunately, IKImageBrowserCell is not a subclass of NSCell, but rather NSObject, and I can't find the solution in the APIs. Any ideas?

like image 325
aneuryzm Avatar asked Nov 04 '22 02:11

aneuryzm


1 Answers

You could try subclassing IKImageBrowserView and adding an NSTrackingArea to the visible rect. You could then implement -mouseMoved: to work with the tracking area to locate the correct image cell using -indexOfItemAtPoint: then get its frame by using -itemFrameAtIndex:.

Rather than try to muck with IKImageBrowserView's black-box layers and drawing, you could add your own layer (or borderless window) above the newly-discovered frame and use standard animations to grow/shrink/animate/glow/shake/whatever this "cheat" cell. Let clicks "pass through" (and hide your "cheat" cell) so the normal drag-and-drop mechanism works the same. IKImageBrowserView has its own -setForegroundLayer: method that allows you to add an "overlay layer" - perfectly suited for this purpose, I'd imagine.

That'd be my first attempt at solving this problem if it were my own.

like image 113
Joshua Nozzi Avatar answered Nov 12 '22 13:11

Joshua Nozzi