From f6d54d810be1d198ff804737a55082a518144a34 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Sun, 2 Nov 2014 07:43:45 +1100 Subject: [PATCH] Improve documentation on getCursorPos and fix cursorInControl. --- Engine/source/gui/core/guiCanvas.cpp | 5 ++++- Engine/source/gui/core/guiControl.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index ad5646fe6..68889af3d 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -2225,7 +2225,10 @@ DefineEngineMethod( GuiCanvas, reset, void, (),, } DefineEngineMethod( GuiCanvas, getCursorPos, Point2I, (),, - "@brief Get the current position of the cursor.\n\n" + "@brief Get the current position of the cursor in screen-space. Note that this position" + " might be outside the Torque window. If you want to get the position within the Canvas," + " call screenToClient on the result.\n\n" + "@see Canvas::screenToClient()\n\n" "@param param Description\n\n" "@tsexample\n" "%cursorPos = Canvas.getCursorPos();\n" diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index 1485f81d8..b52a398b3 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -1427,6 +1427,7 @@ bool GuiControl::cursorInControl() if (! root) return false; Point2I pt = root->getCursorPos(); + pt = root->getPlatformWindow() ? root->getPlatformWindow()->screenToClient(pt) : pt; Point2I extent = getExtent(); Point2I offset = localToGlobalCoord(Point2I(0, 0)); if (pt.x >= offset.x && pt.y >= offset.y &&