Permalink
Browse files

mouseCoords primitive now works

  • Loading branch information...
1 parent e3deff0 commit d2ca4e582a8d69387a016b5106c5ca1832229435 Scott Wilson committed Feb 28, 2010
@@ -3789,50 +3789,15 @@ int prMouse_getCoords(struct VMGlobals *g, int numArgsPushed);
int prMouse_getCoords(struct VMGlobals *g, int numArgsPushed)
{
if (!g->canCallOS) return errCantCallOS;
-
- PyrSlot *b = g->sp;
-
- //#if SC_DARWIN
- /*
- RgnHandle rgn = GetGrayRgn();
- Rect screenBounds;
- GetRegionBounds(rgn, &screenBounds);
- Point p;
- float r_screenWidth = 1. / (screenBounds.right - screenBounds.left);
- float r_screenHeight = 1. / (screenBounds.bottom - screenBounds.top);
- GetGlobalMouse(&p);
- float mouseX = (float)p.h * r_screenWidth;
- float mouseY = (float)p.v * r_screenHeight;
- */
- //bool mouseButton = Button();
- /*
- #else
-
- # ifdef SC_WIN32
- int screenWidth = GetSystemMetrics( SM_CXSCREEN );
- int screenHeight = GetSystemMetrics( SM_CYSCREEN );
- // default: SM_CX/CYSCREEN gets the size of a primary screen.
- // lines uncommented below are just for a specially need on multi-display.
- //int screenWidth = GetSystemMetrics( SM_CXVIRTUALSCREEN );
- //int screenHeight = GetSystemMetrics( SM_CYVIRTUALSCREEN );
- float r_screenWidth = 1.f / (float)(screenWidth -1);
- float r_screenHeight = 1.f / (float)(screenHeight -1);
-
- GetCursorPos(&p);
- float mouseX = (float)p.x * r_screenWidth;
- float mouseY = 1.f - (float)p.y * r_screenHeight;
- bool mouseButton = (GetKeyState(mButton) < 0);
- # else
- # endif
- */
+ PyrSlot *a = g->sp - 1;
+ PyrSlot *b = g->sp;
NSPoint mouse_location = [NSEvent mouseLocation];
PyrSlot *slots = slotRawObject(b)->slots;
SetFloat( slots+0, mouse_location.x );
SetFloat( slots+1, mouse_location.y );
-
- //SetBool(slots+2, mouseButton);
+ slotCopy(a, b);
return errNone;
@@ -4044,7 +4009,7 @@ void initGUIPrimitives()
definePrimitive(base, index++, "_EnableMenuItem", prEnableMenuItem, 2, 0);
definePrimitive(base, index++, "_SetMenuItemState", prSetMenuItemState, 2, 0);
definePrimitive(base, index++, "_SetMenuItemKeyboardEquivalent", prSetMenuItemKeyboardEquivalent, 4, 0);
- definePrimitive(base, index++, "_Mouse_getCoords", prMouse_getCoords, 4, 0);
+ definePrimitive(base, index++, "_Mouse_getCoords", prMouse_getCoords, 2, 0);
definePrimitive(base, index++, "_Recompile", prRecompile, 1, 0);
definePrimitive(base, index++, "_SetDeferredTaskInterval", prSetDeferredTaskInterval, 2, 0);
@@ -50,6 +50,9 @@ Platform
clearMetadata { |path| ^this.subclassResponsibility }
*clearMetadata { |path| ^thisProcess.platform.clearMetadata(path) }
+
+ getMouseCoords { ^this.subclassResponsibility }
+ *getMouseCoords { ^thisProcess.platform.getMouseCoords }
// startup/shutdown hooks
startup { }
@@ -51,5 +51,14 @@ OSXPlatform : UnixPlatform
_Cocoa_HelpFileForString_
^this.primitiveFailed
}
+
+ getMouseCoords {
+ ^this.prGetMouseCoords(Point.new);
+ }
+
+ prGetMouseCoords {|point|
+ _Mouse_getCoords
+ ^this.primitiveFailed
+ }
}

0 comments on commit d2ca4e5

Please sign in to comment.