Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!pequod.cso.uiuc.edu!dorner From: dorner@pequod.cso.uiuc.edu (Steve Dorner) Newsgroups: comp.sys.mac.programmer Subject: Re: Masking Modified Characters Message-ID: <1990Aug16.152714.18081@ux1.cso.uiuc.edu> Date: 16 Aug 90 15:27:14 GMT References: <3903@husc6.harvard.edu> Sender: usenet@ux1.cso.uiuc.edu (News) Reply-To: dorner@pequod.cso.uiuc.edu (Steve Dorner) Organization: University of Illinois at Urbana-Champaign Lines: 45 In article <3903@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes: >How does one avoid getting option-generated characters when using GetNextEvent? >For example, when I type Command-Option-P, I'll an event which tells me I've >typed Command-Option-pi, and I'm more interested in what the unmodified >character was. Is there a standard mask for turning modified characters into >standard ones, or is there some other hack? I have a hack; it's the best way I could come up with, and I think it's compatible, at least with 8 bit languages. Comments, anyone? /************************************************************************ * UnadornMessage - unadorn an event message ************************************************************************/ long UnadornMessage(EventRecord *event) { long message; Handle curKCHR; static long state=0; short key; curKCHR = GetResource('KCHR', GetScript(GetEnvirons(smKeyScript),smScriptKeys)); if (!curKCHR || !event->modifiers&optionKey) message = event->message; else { /* * get what it would have been without the option key */ key = ((event->message>>8)&0xff) | (event->modifiers&(~optionKey)&0xff00); message = KeyTrans(LDRef(curKCHR),key,&state); /* * now massage this into an event "message" */ message = (message & 0xff) | (event->message & 0xff00); } return(message); } -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: {convex,uunet}!uiucuxc!dorner