Custom MouseCursor on OsX


Does anyone have a working example of a custom MouseCursor on osx?
I’ve been trying like this:

void mouseMove(const juce::MouseEvent& e)
  if(getMouseCursor() == MouseCursor::NormalCursor)
                               0, 16));

But without success: the standard cursor is still here.
What exactly are the limitations on the PNG? I tried a 16x16 black&white PNG with transparency, another 24bit PNG, and even a B&W GIF file…


Yes, it works with any semi-transparent image. You only need to call setMouseCursor once in your component’s constructor.

If you’re not seeing it then it’ll be because of some other kind of silly mistake, e.g. your component’s not visible or there’s something in front of it, etc.


Thanks Jules. I made a small test program and used this icon as a test using several sizes.

It turns out 16x16 pixels is too small and won’t display. If I use the size just above, it works. In fact, even resizing to 16x17 with photoshop seems to work…


I think I get it now : it’s not about the size of the picture, rather the int hotSpotX, int hotSpotY coordinates that are passed in the MouseCursor ctor. I had (0, 16) as coordinates for an icon that was exactly 16px tall, my hotSpotY was indeed out of bounds.

Could you maybe add a jassert to ensure this in the future?


That does sound like it’d be helpful, good idea!


even better, you could add a jassert and constrain the point within the image bounds, so that the cursor does change its picture anyway