diff options
author | Just van Rossum <just@letterror.com> | 2002-01-04 19:45:15 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2002-01-04 19:45:15 (GMT) |
commit | c4cf27e8e0280e6963091452a28b0533e6c1b742 (patch) | |
tree | c20de444fa7d990ebec5b2c27986a5cd70de5dc8 /Mac/Modules/ctl/_Ctlmodule.c | |
parent | a22a7b7a06a4b6f0ddabe4898fb008ce8f3b0b17 (diff) | |
download | cpython-c4cf27e8e0280e6963091452a28b0533e6c1b742.zip cpython-c4cf27e8e0280e6963091452a28b0533e6c1b742.tar.gz cpython-c4cf27e8e0280e6963091452a28b0533e6c1b742.tar.bz2 |
- added support for UserPaneKeyDownProc and UserPaneFocusProc
- clear error after failing PyArg_Parse()
Diffstat (limited to 'Mac/Modules/ctl/_Ctlmodule.c')
-rw-r--r-- | Mac/Modules/ctl/_Ctlmodule.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/Mac/Modules/ctl/_Ctlmodule.c b/Mac/Modules/ctl/_Ctlmodule.c index 954beea..cf1c459 100644 --- a/Mac/Modules/ctl/_Ctlmodule.c +++ b/Mac/Modules/ctl/_Ctlmodule.c @@ -132,6 +132,8 @@ DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc static PyObject *tracker; static ControlActionUPP mytracker_upp; static ControlActionUPP myactionproc_upp; +static ControlUserPaneKeyDownUPP mykeydownproc_upp; +static ControlUserPaneFocusUPP myfocusproc_upp; static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; @@ -6513,6 +6515,10 @@ setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr if ( which == kMyControlActionProcTag ) *uppp = (UniversalProcPtr)myactionproc_upp; + else if ( which == kControlUserPaneKeyDownProcTag ) + *uppp = (UniversalProcPtr)mykeydownproc_upp; + else if ( which == kControlUserPaneFocusProcTag ) + *uppp = (UniversalProcPtr)myfocusproc_upp; else if ( which == kControlUserPaneDrawProcTag ) *uppp = (UniversalProcPtr)mydrawproc_upp; else if ( which == kControlUserPaneIdleProcTag ) @@ -6570,6 +6576,42 @@ myactionproc(ControlHandle control, SInt16 part) Py_XDECREF(rv); } +static pascal ControlPartCode +mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) +{ + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = 0; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers); + rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist); + Py_XDECREF(arglist); + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; +} + +static pascal ControlPartCode +myfocusproc(ControlHandle control, ControlPartCode part) +{ + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = kControlFocusNoPart; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Oh", ctl_obj, part); + rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist); + Py_XDECREF(arglist); + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; +} + static pascal void mydrawproc(ControlHandle control, SInt16 part) { @@ -6609,7 +6651,8 @@ myhittestproc(ControlHandle control, Point where) Py_XDECREF(arglist); /* Ignore errors, nothing we can do about them */ if ( rv ) - PyArg_Parse(rv, "h", &c_rv); + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); Py_XDECREF(rv); return (ControlPartCode)c_rv; } @@ -6627,7 +6670,8 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); Py_XDECREF(arglist); if ( rv ) - PyArg_Parse(rv, "h", &c_rv); + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); Py_XDECREF(rv); return (ControlPartCode)c_rv; } @@ -6642,6 +6686,8 @@ void init_Ctl(void) mytracker_upp = NewControlActionUPP(mytracker); myactionproc_upp = NewControlActionUPP(myactionproc); + mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc); + myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc); mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc); myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc); myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc); |