# Custom MouseCursor on OsX

**URL:** <https://forum.juce.com/t/custom-mousecursor-on-osx/24944>\
**Category:** MacOSX and iOS\
**Created:** [November 1, 2017, 9:22pm UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944 "2017-11-01T21:22:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dri](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dri/32/142_2.png) [@Dri](https://forum.juce.com/u/Dri)\
**Post date:** [November 1, 2017, 9:22pm UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/1 "2017-11-01T21:22:23Z")

</div>

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)
  {        
    setMouseCursor(MouseCursor(ImageCache::getFromMemory(mycursor_png,
                                                         mycursor_pngSize),
                               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…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2017, 8:18am UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/2 "2017-11-02T08:18:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dri](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dri/32/142_2.png) [@Dri](https://forum.juce.com/u/Dri)\
**Post date:** [November 2, 2017, 11:10am UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/3 "2017-11-02T11:10:33Z")

</div>

Thanks Jules. I made a small test program and used [this icon as a test](https://www.flaticon.com/free-icon/pencil-cursor_63612#) 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…

---

<div class="post-metadata">

**Author:** ![Dri](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dri/32/142_2.png) [@Dri](https://forum.juce.com/u/Dri)\
**Post date:** [November 2, 2017, 12:16pm UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/4 "2017-11-02T12:16:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2017, 2:22pm UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/5 "2017-11-02T14:22:39Z")

</div>

> [@Dri](#):
>
> Could you maybe add a jassert to ensure this in the future?

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

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [November 2, 2017, 3:41pm UTC](https://forum.juce.com/t/custom-mousecursor-on-osx/24944/6 "2017-11-02T15:41:09Z")

</div>

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