Skip to content

Commit ec0107f

Browse files
committed
Today's Carbon Toolbox addition: CarbonEvt.TrackMouseLocation() and friends.
1 parent 925f144 commit ec0107f

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

Mac/Modules/carbonevt/CarbonEvtscan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def makeblacklistnames(self):
6363
return [
6464
"sHandler",
6565
"MacCreateEvent",
66-
"TrackMouseLocationWithOptions",
67-
"TrackMouseLocation",
68-
"TrackMouseRegion",
66+
# "TrackMouseLocationWithOptions",
67+
# "TrackMouseLocation",
68+
# "TrackMouseRegion",
6969
"RegisterToolboxObjectClass",
7070
"UnregisterToolboxObjectClass",
7171
"ProcessHICommand",

Mac/Modules/carbonevt/CarbonEvtsupport.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def precheck(self):
6868
OutRbrace()
6969

7070

71+
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
72+
GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
73+
MouseTrackingResult = UInt16
74+
75+
7176
includestuff = r"""
7277
#ifdef WITHOUT_FRAMEWORKS
7378
#include <CarbonEvents.h>

Mac/Modules/carbonevt/_CarbonEvtmodule.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,78 @@ static PyObject *CarbonEvents_GetCurrentEventTime(PyObject *_self, PyObject *_ar
13901390
return _res;
13911391
}
13921392

1393+
static PyObject *CarbonEvents_TrackMouseLocation(PyObject *_self, PyObject *_args)
1394+
{
1395+
PyObject *_res = NULL;
1396+
OSStatus _err;
1397+
GrafPtr inPort;
1398+
Point outPt;
1399+
UInt16 outResult;
1400+
if (!PyArg_ParseTuple(_args, "O&",
1401+
GrafObj_Convert, &inPort))
1402+
return NULL;
1403+
_err = TrackMouseLocation(inPort,
1404+
&outPt,
1405+
&outResult);
1406+
if (_err != noErr) return PyMac_Error(_err);
1407+
_res = Py_BuildValue("O&H",
1408+
PyMac_BuildPoint, outPt,
1409+
outResult);
1410+
return _res;
1411+
}
1412+
1413+
static PyObject *CarbonEvents_TrackMouseLocationWithOptions(PyObject *_self, PyObject *_args)
1414+
{
1415+
PyObject *_res = NULL;
1416+
OSStatus _err;
1417+
GrafPtr inPort;
1418+
OptionBits inOptions;
1419+
double inTimeout;
1420+
Point outPt;
1421+
UInt32 outModifiers;
1422+
UInt16 outResult;
1423+
if (!PyArg_ParseTuple(_args, "O&ld",
1424+
GrafObj_Convert, &inPort,
1425+
&inOptions,
1426+
&inTimeout))
1427+
return NULL;
1428+
_err = TrackMouseLocationWithOptions(inPort,
1429+
inOptions,
1430+
inTimeout,
1431+
&outPt,
1432+
&outModifiers,
1433+
&outResult);
1434+
if (_err != noErr) return PyMac_Error(_err);
1435+
_res = Py_BuildValue("O&lH",
1436+
PyMac_BuildPoint, outPt,
1437+
outModifiers,
1438+
outResult);
1439+
return _res;
1440+
}
1441+
1442+
static PyObject *CarbonEvents_TrackMouseRegion(PyObject *_self, PyObject *_args)
1443+
{
1444+
PyObject *_res = NULL;
1445+
OSStatus _err;
1446+
GrafPtr inPort;
1447+
RgnHandle inRegion;
1448+
Boolean ioWasInRgn;
1449+
UInt16 outResult;
1450+
if (!PyArg_ParseTuple(_args, "O&O&",
1451+
GrafObj_Convert, &inPort,
1452+
ResObj_Convert, &inRegion))
1453+
return NULL;
1454+
_err = TrackMouseRegion(inPort,
1455+
inRegion,
1456+
&ioWasInRgn,
1457+
&outResult);
1458+
if (_err != noErr) return PyMac_Error(_err);
1459+
_res = Py_BuildValue("bH",
1460+
ioWasInRgn,
1461+
outResult);
1462+
return _res;
1463+
}
1464+
13931465
static PyObject *CarbonEvents_GetLastUserEventTime(PyObject *_self, PyObject *_args)
13941466
{
13951467
PyObject *_res = NULL;
@@ -1718,6 +1790,12 @@ static PyMethodDef CarbonEvents_methods[] = {
17181790
"() -> (EventQueueRef _rv)"},
17191791
{"GetCurrentEventTime", (PyCFunction)CarbonEvents_GetCurrentEventTime, 1,
17201792
"() -> (double _rv)"},
1793+
{"TrackMouseLocation", (PyCFunction)CarbonEvents_TrackMouseLocation, 1,
1794+
"(GrafPtr inPort) -> (Point outPt, UInt16 outResult)"},
1795+
{"TrackMouseLocationWithOptions", (PyCFunction)CarbonEvents_TrackMouseLocationWithOptions, 1,
1796+
"(GrafPtr inPort, OptionBits inOptions, double inTimeout) -> (Point outPt, UInt32 outModifiers, UInt16 outResult)"},
1797+
{"TrackMouseRegion", (PyCFunction)CarbonEvents_TrackMouseRegion, 1,
1798+
"(GrafPtr inPort, RgnHandle inRegion) -> (Boolean ioWasInRgn, UInt16 outResult)"},
17211799
{"GetLastUserEventTime", (PyCFunction)CarbonEvents_GetLastUserEventTime, 1,
17221800
"() -> (double _rv)"},
17231801
{"GetWindowEventTarget", (PyCFunction)CarbonEvents_GetWindowEventTarget, 1,

0 commit comments

Comments
 (0)