Converting mouse coordinates in fullscreen context?
Converting mouse coordinates in fullscreen context?
- Subject: Converting mouse coordinates in fullscreen context?
- From: arekkusu <email@hidden>
- Date: Mon, 24 Feb 2003 21:59:55 -0800
(I posted this to mac-opengl last week, no replies. So cross-posting to
this list now in hopes of more eyes looking at it...)
I need to get the mouse coordinates in a fullscreen game context.
Unrelated factors (minification, etc) have steered my event handling
approach to:
1) controller is subclass of NSResponder, and implements mouseDown: etc
for normal windowed mode.
2) window is created programatically and has the controller as
nextResponder during windowed mode (for keystroke handling.)
3) window's first responder is swapped to the controller when in
fullscreen mode, so all events (escape key, mouse) are caught. The
event handler just passes relevant events to the normal mouseDown: etc
handlers.
Here's my problem: in windowed mode I am getting sensible mouse
coordinates via:
- (void) mouseDown:(NSEvent*)event{
NSPoint loc = [viewport convertPoint:[event locationInWindow]
fromView:nil];
NSLog(@"mouse down (%@): (%f, %f)", event, loc.x, loc.y);
}
e.g. from (0,0) to (639,399) in a 640x400 window (although the resize
widget obscures one corner, as expected.)
But, in a fullscreen context, 896x600 for example, the same function
reports mouse coordinates from (0, -454) to (895, 145).
The vertical coordinates change depending on how big the (windowed
mode) window is, but they always include some negative values.
Looking at the event, winNum is changing each time I enter fullscreen
mode; I guess it's a temporary shielding window CG creates? How can I
get the fullscreen window's coordinate system to make sense?
My view returns YES for isFlipped, if that makes any difference. The
coordinates are totally screwed up when my fullscreen context is on a
second display; they look more like global coordinates, as if
convertPoint: hasn't done anything. Is convertPoint: just broken with
fullscreen contexts? I'll gladly log a bug unless somebody shows me
what I'm doing wrong...
thanks,
-alex
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.