Featured post
osx - Mac Mouse Coordinates != Window Frame? -
here's issue. can explain enough. desktop 2x2 monitors of size (2048,1152).
i'm trying use ancillary device generate mouse clicks. mouse click supposed on coordinate (1600,1407)-ish (on "pan button"), assuming (0,0) top-left of entire desktop area. moves mouse correct position, when perform cgrectcontainspoint()
) gives me no
result.
the rectangle(frame) given pop-up window has origin of (1558,-406)? math correct cgrectcontainspoint()
, window's frame should contain point. (even more can see mouse cursor on window.)
why? because child window? (center of desktop in center of image, each window different background color.)
i have tried using following:
nsrect pframe = [_popupwindow frame]; nspoint porigin = pframe.origin; nspoint correctedorigin = [[_popupwindow parentwindow] convertbasetoscreen:porigin]; pframe.origin = correctedorigin;
but gives me:
... rect {{1488, -1529}, {439, 306}}, point {1556.17, 1314.76}, inrect 0
as result, still doesn't place point (which can see hovering on pop-up window) in rect.
why rect popup window , point not remotely same? how can them in same coordinate "space"?
thanks,
on mac, (0,0) in bottom-left corner. how getting mouse coordinates? window's frame in screen coordinates, if point in it's base coordinates need call point = [window convertbasetoscreen:point];
before comparing.
here 2 ways mouse location in cocoa:
nspoint location = [nsevent mouselocation]; //already in screen coordinates, no need convert
or
//window variable containing window nspoint location = [window mouselocationoutsideofeventstream]; //convert screen coordinates location = [window convertbasetoscreen:location];
- Get link
- X
- Other Apps
Comments
Post a Comment