Re: Key Trapping in win32lib
- Posted by Grape_ Vine_ <g__vine at HOTMAIL.COM> Feb 27, 2000
- 461 views
I assume the onKeyPress is a key is held down?? (that is part of what i need) Doing this in dos was faster, Once you figured out how.... J Reeves Grape Vine ICQ# 13728824 >From: David Cuny <dcuny at LANSET.COM> >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: Re: Key Trapping in win32lib >Date: Sun, 27 Feb 2000 10:51:37 -0800 > >J Reeves wrote: > > > > How do i setup key trapping in win32lib? > >Win32Lib traps key events through two seperate events. You can get 'raw' >key >events through onKeyUp and onKeyDown, and ANSI key events through >onKeyPress. > >It's a bit weird, but it's based on how Windows is designed. The main event >loop for most Windows applications looks something like this: > > -- read event queue until WM_QUIT message received > while GetEvent() != 0 do > -- trigger the application's callback > DispatchMessage() > end while > >Using this, your application ends up with only 'raw' (non-ANSI) keystrokes. >Adding a call to TranslateMessage converts the keys to ANSI (it applies the >right shift key flags to it, etc.): > > -- read event queue until WM_QUIT message received > while GetEvent() != 0 do > -- convert the onKeyPress message > TranslateMessage() > -- trigger the application's callback > DispatchMessage() > end while > >But there is no 'ANSI' coding for the cursor keys, etc. So you need to use >onKeyDown to trap non-printable characters, and onKeyPress to capture >printable chars. At some point I may unify the code by adding an 'Ansi' >flag >to onKeyDown, but for now it's a bit clunky. > >Hope this helps! > >-- David Cuny ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com