Hi,
I’m wanting to track the coordinates of the mouse in my OSX app when it’s just moving (i.e.: no click has yet been made) so I can use a custom cursor/pointer that is larger than the default one. I can’t remove the default one yet (Corona doesn’t yet support this) but in certain areas of my app, having the larger pointer as well will make life easier for people.
I’m using the below code and in the simulator, it works fine, but as soon as I publish to OSX, I only get an update when I hold down the left mouse button and move the mouse. If I just move without clicking I get nothing…
Any idea what I’m doing wrong?
Thanks,
Ian
function MousePointer:add(layer) --\>\>\>\>\>\> Add the graphical mouse pointer local mousePointer = display.newImageRect("mouse-pointer.png", 40, 40); layer:insert( mousePointer, true ); mousePointer.anchorX = 0.32; mousePointer.anchorY = 0.2; --\>\>\>\>\>\> Start the mouse pointer off screen until it moves mousePointer.x = -100; mousePointer.y = -100; --\>\>\>\>\>\> Set a mouseTo (for smoother animation) local mouseTo = {px=-100,py=-100}; --\>\>\>\>\>\> Change the mouseTo coordinates as the mouse moves local function onMouseEventPointer( e ) mouseTo.px = e.x; mouseTo.py = e.y; end --\>\>\>\>\>\>\> Update the graphical pointer's position based on mouseTo coords local function onEnterFramePointer( e ) mousePointer.x = mousePointer.x + (mouseTo.px - mousePointer.x)/2; mousePointer.y = mousePointer.y + (mouseTo.py - mousePointer.y)/2; end Runtime:addEventListener( "mouse", onMouseEventPointer ); Runtime:addEventListener( "enterFrame", onEnterFramePointer ); end