Menu

#60 Picking on Windows does not match Mac

open
nobody
None
5
2004-03-01
2004-03-01
No

Joe Strout wrote:

There's a bug with picking in Win32, where in order to get the
correct result, you have to adjust the window coordinates passed in
by a certain scale factor that varies from machine to machine. My
guess is that this relates somehow to the resolution of the screen.
Perhaps we're somewhere using pixels where we should be using
points, or vice versa.

We've found more information about the odd picking bug on Win32.
In order to get the pick to work correctly, you have to apply a
scaling factor that depends on both the screen size and the view
size and position. In RB code, it looks like this:

#If TargetWin32
x2 = x * Screen(0).width / Rb3DSpace1.width - Rb3DSpace1.left
y2 = y * Screen(0).height / Rb3DSpace1.height -
Rb3DSpace1.top
#Else
x2 = x // All works as expected on the Mac
y2 = y
#Endif

// (and then pass x2, y2 to the picking function)

So, for both X and Y, we have to multiply by the ratio of the screen
size to view size, and then subtract off the top/left of the view (so
that the coordinates are now relative to the view rather than the
window).

On the Mac none of that is necessary; we just pass in window
coordinates and it works.

Discussion


Log in to post a comment.