Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0437e89

Browse files
committed
fix bug in filterproc interface
1 parent f74c36c commit 0437e89

4 files changed

Lines changed: 28 additions & 38 deletions

File tree

Mac/Lib/test/tdlg.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
# This program requires that a DLOG resource with ID=128 exists.
2-
# You can make one with ResEdit if necessary.
1+
# Function to display a message and wait for the user to hit OK.
2+
# This uses a DLOG resource with ID=256 which is part of the standard
3+
# Python library.
4+
# The ID can be overridden by passing a second parameter.
35

4-
from Res import *
56
from Dlg import *
7+
from Events import *
8+
import string
69

7-
ires = 128
10+
ID = 256
811

9-
def filter(*args): print 'filter:', args
12+
def f(d, event):
13+
what, message, when, where, modifiers = event
14+
if what == keyDown and modifiers & cmdKey and \
15+
string.lower(chr(message & charCodeMask)) == 'o':
16+
return 1
1017

11-
d = GetNewDialog(ires, -1)
12-
while 1:
13-
n = ModalDialog(filter)
14-
print 'item:', n
15-
if n == 1: break
18+
def message(str = "Hello, world!", id = ID):
19+
d = GetNewDialog(id, -1)
20+
tp, h, rect = d.GetDItem(2)
21+
SetIText(h, str)
22+
while 1:
23+
n = ModalDialog(f)
24+
if n == 1: break
25+
26+
def test():
27+
message()
28+
29+
if __name__ == '__main__':
30+
test()

Mac/Modules/dlg/Dlgmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
5555
if (callback == NULL)
5656
return 0; /* Default behavior */
5757
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
58-
args = Py_BuildValue("O&s#", DlgObj_New, dialog, event, (int)sizeof(EventRecord));
58+
args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
5959
if (args == NULL)
6060
res = NULL;
6161
else {

Mac/Modules/dlg/dlggen.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
)
2121
functions.append(f)
2222

23-
f = Function(void, 'CouldDialog',
24-
(short, 'dialogID', InMode),
25-
)
26-
functions.append(f)
27-
28-
f = Function(void, 'FreeDialog',
29-
(short, 'dialogID', InMode),
30-
)
31-
functions.append(f)
32-
3323
f = Function(void, 'ParamText',
3424
(ConstStr255Param, 'param0', InMode),
3525
(ConstStr255Param, 'param1', InMode),
@@ -61,12 +51,6 @@
6151
)
6252
methods.append(f)
6353

64-
f = Method(void, 'UpdtDialog',
65-
(DialogPtr, 'theDialog', InMode),
66-
(RgnHandle, 'updateRgn', InMode),
67-
)
68-
methods.append(f)
69-
7054
f = Method(void, 'UpdateDialog',
7155
(DialogPtr, 'theDialog', InMode),
7256
(RgnHandle, 'updateRgn', InMode),
@@ -97,16 +81,6 @@
9781
)
9882
functions.append(f)
9983

100-
f = Function(void, 'CouldAlert',
101-
(short, 'alertID', InMode),
102-
)
103-
functions.append(f)
104-
105-
f = Function(void, 'FreeAlert',
106-
(short, 'alertID', InMode),
107-
)
108-
functions.append(f)
109-
11084
f = Method(void, 'GetDItem',
11185
(DialogPtr, 'theDialog', InMode),
11286
(short, 'itemNo', InMode),
@@ -222,3 +196,4 @@
222196
(short, 'numberItems', InMode),
223197
)
224198
methods.append(f)
199+

Mac/Modules/dlg/dlgsupport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
if (callback == NULL)
4141
return 0; /* Default behavior */
4242
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
43-
args = Py_BuildValue("O&s#", DlgObj_New, dialog, event, (int)sizeof(EventRecord));
43+
args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
4444
if (args == NULL)
4545
res = NULL;
4646
else {

0 commit comments

Comments
 (0)