Fix for Cursor Position Incorrectly Calculated


14-05-2008 01:44:54


I noticed that buttons were not being highlighted accurately when the tip of the pointer was over them. As you know, the button ought to have its 'over' texture on from when the very point of the cursor enters its lower bounds, to when that same point leaves the top. The point that's first in and first out should trigger the changes.

This wasn't happening for me -- the texture was changing when the cursor was about halfway onto the button already.


Point MouseCursor::getPosition()
//return Point(mPixelPosition.x + (mPixelSize.width/2.0),mPixelPosition.y + (mPixelSize.height/2.0));
return Point(mPixelPosition.x,mPixelPosition.y);

Just comment the code in MouseCursor::getPosition() as I have done above, and replace it with the uncommented line I added. Calculating the mean centre of the cursor, as you had done above, is not appropriate for cursors, whose tip should always be at the top left, very top of the texture.

Could you add the fix to SVN please? I've long since lost my commit rights!




14-05-2008 05:46:20

I think your cursor image might be out of date. The cursor's position should be the center and not the top left of the image. This is the same on Windows OS, and if you're still not convinced, move the mouse cursor near a window edge. As soon as the tip of the cursor moves over the border, the resize cursor appears. In particular, if you mouse over the border sides, you'll see the resize cursor is centered where the pointing cursor's tip (center) used to be. The reason for my calculations is that I have to manage the Texture position and the Cursor position, which unlike Widgets are not the same.


14-05-2008 23:27:01


I did have an old cursor, so that explains that.

In point of fact though, on XP at least if you load up the cursors in the C:\WINDOWS\Cursors folder using VC++, you can see that the tips of the cursors are in the top-left corner. However, this means that Windows must be figuring out where the 'tip' of a cursor is, dependent on its type, so that resize cursors etc appear at the right point even though their relevant points are not at the edge of the texture as the normal cursor's is.

The new QuickGUI cursor's a little nasty though, methinks! Seems skewed, somehow. Might have to put the old one back and just centre it in the texture.