Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!hellgate.utah.edu!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: What's wrong with this ModalDialog filterproc? Message-ID: <4530@helios.ee.lbl.gov> Date: 27 Dec 89 18:40:32 GMT References: <10125@saturn.ucsc.edu> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 24 X-Local-Date: 27 Dec 89 10:40:32 PST In article <10125@saturn.ucsc.edu> sirkm@ssyx.ucsc.edu (Greg Anderson) writes: >I wrote a filterproc for ModalDialog that allows the user to cut, copy >and paste to fields in a modal dialog box by pressing command-c, command-x >and command-v, respectively. The filterproc works great--cutting and >pasting work as expected. However, if the user presses , >ModalDialog no longer returns with itemHit = 1. ... >pascal int cutPasteFilter( DialogPtr dlog, EventRecord *theEvent, int *itemHit ) ^^^ ^^^ Boom. You've been burned by MPW C. MPW C's "int" is really a "long". i.e. 32 bits. When writing routines that will be called from the toolbox, pascal integers map to C "short"s. So, the fix is: pascal short cutPasteFilter(DialogPtr dlg, EventRecord *evt, short *itemHit) { ... } Hope that helps. ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------