fix bug in filterproc interface

This commit is contained in:
Guido van Rossum 1995-02-21 20:56:21 +00:00
parent f74c36c9dc
commit 0437e89041
4 changed files with 28 additions and 38 deletions

View File

@ -1,15 +1,30 @@
# This program requires that a DLOG resource with ID=128 exists. # Function to display a message and wait for the user to hit OK.
# You can make one with ResEdit if necessary. # 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 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) def message(str = "Hello, world!", id = ID):
while 1: d = GetNewDialog(id, -1)
n = ModalDialog(filter) tp, h, rect = d.GetDItem(2)
print 'item:', n SetIText(h, str)
if n == 1: break while 1:
n = ModalDialog(f)
if n == 1: break
def test():
message()
if __name__ == '__main__':
test()

View File

@ -55,7 +55,7 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
if (callback == NULL) if (callback == NULL)
return 0; /* Default behavior */ return 0; /* Default behavior */
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ 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) if (args == NULL)
res = NULL; res = NULL;
else { else {

View File

@ -20,16 +20,6 @@
) )
functions.append(f) 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', f = Function(void, 'ParamText',
(ConstStr255Param, 'param0', InMode), (ConstStr255Param, 'param0', InMode),
(ConstStr255Param, 'param1', InMode), (ConstStr255Param, 'param1', InMode),
@ -61,12 +51,6 @@
) )
methods.append(f) methods.append(f)
f = Method(void, 'UpdtDialog',
(DialogPtr, 'theDialog', InMode),
(RgnHandle, 'updateRgn', InMode),
)
methods.append(f)
f = Method(void, 'UpdateDialog', f = Method(void, 'UpdateDialog',
(DialogPtr, 'theDialog', InMode), (DialogPtr, 'theDialog', InMode),
(RgnHandle, 'updateRgn', InMode), (RgnHandle, 'updateRgn', InMode),
@ -97,16 +81,6 @@
) )
functions.append(f) 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', f = Method(void, 'GetDItem',
(DialogPtr, 'theDialog', InMode), (DialogPtr, 'theDialog', InMode),
(short, 'itemNo', InMode), (short, 'itemNo', InMode),
@ -222,3 +196,4 @@
(short, 'numberItems', InMode), (short, 'numberItems', InMode),
) )
methods.append(f) methods.append(f)

View File

@ -40,7 +40,7 @@
if (callback == NULL) if (callback == NULL)
return 0; /* Default behavior */ return 0; /* Default behavior */
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ 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) if (args == NULL)
res = NULL; res = NULL;
else { else {