Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!rutgers!mephisto!purdue!decwrl!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: What's wrong with this ModalDialog filterproc? Message-ID: <9418@hoptoad.uucp> Date: 27 Dec 89 22:14:32 GMT References: <10125@saturn.ucsc.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 52 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. > >I'm using the MPW C. Here's the filterProc: > >pascal int cutPasteFilter(DialogPtr dlog, EventRecord *theEvent, int *itemHit) ints are four bytes in MPW C. INTEGERs are two bytes in Mac Pascals. When the type INTEGER occurs in Inside Macintosh, you need to translate it as "short", not as "int"; and leave Boolean as Boolean (it's defined in types.h). This should solve your problem. Change your declaration to: pascal Boolean cutPasteFilter(DialogPtr dlog, EventRecord *theEvent, short *itemHit) > if( theEvent->modifiers & cmdKey ) > { > switch( key ) > { > case 'x': > ZeroScrap(); > DlgCut( dlog ); > if( TEToScrap() != noErr ) > SysBeep(0); > break; > > case 'c': And so on. You have an internationalization problem here. These codes are surely not the same under all langauges. I assume this is in an application, so the best way to handle the equivalencies is using your own Edit menu. Call MenuKey to translate the character into a menu command; then do this edit processing if the menu id is the id of your edit menu, and switch on the menu item number rather than on the character typed. (If you didn't have an edit menu handy in the menu bar -- for instance, in a DA running under an application with an unknown edit menu id -- then you would have to keep a STR# resource to keep track of the appropriate shortcuts for editing.) -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "He goes on about the wailing and gnashing of teeth. It comes in one verse after another, and it is quite manifest to the reader that there is a certain pleasure in contemplating the wailing and gnashing of teeth, or else it would not occur so often." -- Bertrand Russell, "Why I Am Not a Christian"