1. Key Trapping in win32lib
- Posted by Grape_ Vine_ <g__vine at HOTMAIL.COM> Feb 27, 2000
- 476 views
How do i setup key trapping in win32lib? I tried onKeyPress[ GW ] = routine_id("onKeyPress_Control" ) where onKeyPress_Control is the procedure for processing arrow keys J Reeves Grape Vine ICQ# 13728824 ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
2. Re: Key Trapping in win32lib
- Posted by David Cuny <dcuny at LANSET.COM> Feb 27, 2000
- 459 views
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
3. 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
4. Re: Key Trapping in win32lib
- Posted by David Cuny <dcuny at LANSET.COM> Feb 27, 2000
- 455 views
- Last edited Feb 28, 2000
J Reeves wrote: > I assume the onKeyPress is a key is held down?? Yes, and onKeyRelease is the release of a key. > Doing this in dos was faster, Once you figured out how.... Everyone's a critic. Actually, the onKeyPress and onKeyRelease are very much like getting raw information in DOS - they return the scan code. The project I'm currently writing unifies the two like this: procedure OnKeyPress( integer key, integer mask ) Key( key, mask, True ) end procedure onKeyPress[Win] = routine_id("OnKeyPress") procedure OnKeyDown( integer key, integer mask ) Key( key, mask, False ) end procedure onKeyDown[Win] = routine_id("OnKeyDown") The key processing code looks something like: procedure Key( integer key, integer mask, integer raw ) if key = 'a' and not raw then -- trapping a character elsif key = VK_PRIOR and raw then -- handle page up end if end procedure Hope this helps! -- David Cuny