Due to a rounding discrepancy, a component can receive a mouseEnter event while isMouseOver returns false.
NSViewComponentPeer::getMousePos which uses c-style casts.
static Point<int> getMousePos (NSEvent* e, NSView* view)
{
NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil];
//old using c-style casts
//return Point<int> ((int) p.x, (int) ([view frame].size.height - p.y));
//proposed fix uses roundToInt to be consistent
//with MouseInputSource::getCurrentRawMousePosition
return Point<int> (roundToInt(p.x), roundToInt([view frame].size.height - p.y));
}
juce_mac_Windowing.mm MouseInputSource::getCurrentRawMousePosition uses roundToInt:
Point<int> MouseInputSource::getCurrentRawMousePosition()
{
JUCE_AUTORELEASEPOOL
{
const NSPoint p ([NSEvent mouseLocation]);
//using roundToInt here
return Point<int> (roundToInt (p.x), roundToInt (getMainScreenHeight() - p.y));
}
}
I've tested with them both using roundToInt and it fixes the problem. That said, it looks like roundToInt isn't used much with other platforms, so perhaps the fix should go the other way around.
iOS UIViewComponentPeer::handleTouches (c-style) e.g.:
const Point<int> pos ((int) p.x, (int) p.y); juce_lastMousePos = pos + getBounds (true).getPosition();
And for Android (Point.toInt() uses static_cast<int>):
void handleMouseDownCallback (int index, Point<float> pos, int64 time)
{
lastMousePos = pos;
// this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before.
handleMouseEvent (index, pos.toInt(), currentModifiers.withoutMouseButtons(), time);
