]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix bug in filterproc interface
authorGuido van Rossum <guido@python.org>
Tue, 21 Feb 1995 20:56:21 +0000 (20:56 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 21 Feb 1995 20:56:21 +0000 (20:56 +0000)
Mac/Lib/test/tdlg.py
Mac/Modules/dlg/Dlgmodule.c
Mac/Modules/dlg/dlggen.py
Mac/Modules/dlg/dlgsupport.py

index f234a701998e59dc80b0c6e5ee46520e18bc8eb7..d6fdd978ee26448a3dbc9e18f49371ef51393edf 100644 (file)
@@ -1,15 +1,30 @@
-# This program requires that a DLOG resource with ID=128 exists.
-# You can make one with ResEdit if necessary.
+# Function to display a message and wait for the user to hit OK.
+# This uses a DLOG resource with ID=256 which is part of the standard
+# Python library.
+# The ID can be overridden by passing a second parameter.
 
-from Res import *
 from Dlg import *
+from Events import *
+import string
 
-ires = 128
+ID = 256
 
-def filter(*args): print 'filter:', args
+def f(d, event):
+       what, message, when, where, modifiers = event
+       if what == keyDown and modifiers & cmdKey and \
+          string.lower(chr(message & charCodeMask)) == 'o':
+               return 1
 
-d = GetNewDialog(ires, -1)
-while 1:
-       n = ModalDialog(filter)
-       print 'item:', n
-       if n == 1: break
+def message(str = "Hello, world!", id = ID):
+       d = GetNewDialog(id, -1)
+       tp, h, rect = d.GetDItem(2)
+       SetIText(h, str)
+       while 1:
+               n = ModalDialog(f)
+               if n == 1: break
+
+def test():
+       message()
+
+if __name__ == '__main__':
+       test()
index 0cd9dbb916e59250a2ca9acf0ed6fd5a129d7494..b297e1c469a4c4e94d8b95d69b5e4c820fabaf9f 100644 (file)
@@ -55,7 +55,7 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
        if (callback == NULL)
                return 0; /* Default behavior */
        Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
-       args = Py_BuildValue("O&s#", DlgObj_New, dialog, event, (int)sizeof(EventRecord));
+       args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
        if (args == NULL)
                res = NULL;
        else {
index ea64ab76758176e097335d832779a17f3ebd5524..bd65cd05c01075eeb209be7638e4f03e31151abd 100644 (file)
@@ -20,16 +20,6 @@ f = Function(DialogPtr, 'GetNewDialog',
 )
 functions.append(f)
 
-f = Function(void, 'CouldDialog',
-    (short, 'dialogID', InMode),
-)
-functions.append(f)
-
-f = Function(void, 'FreeDialog',
-    (short, 'dialogID', InMode),
-)
-functions.append(f)
-
 f = Function(void, 'ParamText',
     (ConstStr255Param, 'param0', InMode),
     (ConstStr255Param, 'param1', InMode),
@@ -61,12 +51,6 @@ f = Method(void, 'DrawDialog',
 )
 methods.append(f)
 
-f = Method(void, 'UpdtDialog',
-    (DialogPtr, 'theDialog', InMode),
-    (RgnHandle, 'updateRgn', InMode),
-)
-methods.append(f)
-
 f = Method(void, 'UpdateDialog',
     (DialogPtr, 'theDialog', InMode),
     (RgnHandle, 'updateRgn', InMode),
@@ -97,16 +81,6 @@ f = Function(short, 'CautionAlert',
 )
 functions.append(f)
 
-f = Function(void, 'CouldAlert',
-    (short, 'alertID', InMode),
-)
-functions.append(f)
-
-f = Function(void, 'FreeAlert',
-    (short, 'alertID', InMode),
-)
-functions.append(f)
-
 f = Method(void, 'GetDItem',
     (DialogPtr, 'theDialog', InMode),
     (short, 'itemNo', InMode),
@@ -222,3 +196,4 @@ f = Method(void, 'ShortenDITL',
     (short, 'numberItems', InMode),
 )
 methods.append(f)
+
index 1eb5576fbbadfcc4984d5888c0e74422c862c170..d3491fe5c94b53c9cef53b0d59d6bf7b9ab77695 100644 (file)
@@ -40,7 +40,7 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
        if (callback == NULL)
                return 0; /* Default behavior */
        Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
-       args = Py_BuildValue("O&s#", DlgObj_New, dialog, event, (int)sizeof(EventRecord));
+       args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
        if (args == NULL)
                res = NULL;
        else {