hit = true;
// we were hovering over another id and now we're hovering over nothing or a new id - send a mouse out event
if (fLastId != null && fLastId != id) {
Handlers handlers = fIdToHandlers.get(fLastId);
if (handlers != null && handlers.mouseOutHandler != null) handlers.mouseOutHandler.onMouseOut(new Vector2(x, y));
fLastId = null;
}
// we enter a new object
if (fLastId == null) {
fLastId = id;
Handlers handlers = fIdToHandlers.get(fLastId);
if (handlers != null && handlers.mouseOverHandler != null) handlers.mouseOverHandler.onMouseOver(new Vector2(x, y), fLastId);
}
// we were already on this object, but we moved the mouse
else {
Handlers handlers = fIdToHandlers.get(fLastId);
if (handlers != null && handlers.mouseMoveHandler != null) handlers.mouseMoveHandler.onMouseMove(new Vector2(x, y), fLastId);
}
// only process one hit
break;
}
}
// update drag
if (fStartDragLoc != null) {
for (SurfaceMouseDragHandler handler : fDragHandlers) {
handler.onDragChange(fStartDragLoc, new Vector2(x, y), fStartDragId, fLastId);
}
}
// we got here - this means there was no hit
// if we were above an object in the previous cycle, let it know we left
if (!hit) {
Handlers handlers = fIdToHandlers.get(fLastId);
if (handlers != null && handlers.mouseOutHandler != null) handlers.mouseOutHandler.onMouseOut(new Vector2(x, y));
fLastId = null;
}
}