Re: beeps
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 24, 2004
- 564 views
George Walters wrote: > > > Well, putting in some dots to indicate missing code ended up deleting the rest > of my > message so I removed them and here it is. > > > I'm trying to discover why windows beeps when I "tab" through fields. It does > not beep > when I "arrow" throught fields and in my code there is no (apparent to me) > difference > between tabbing and arrowing. Look at this code [code snipped] It is beeping because the TAB key is being processed by the Edit field's default Microsoft process. Normally, win32lib traps the TAB key and tabs around the display, but because you set tabcodes to zero, Win32lib is passing the TAB press to the edit file. I would recommend you do the following... a) Create a new routine to JUST move the focus depending on the UP/DOWN direction and the current focus. b) Set a handler to trap w32HKeyPress and if you get a TAB key, call returnValue(-1). And that's all that this handler does. c) Set a handler to trap w32HKeyDown. Have this translate TAN keys into UP or DOWN depending on the shift key. The if you have an UP or DOWN, call the focus setting routine. Here is some sample code:
include win32lib.ew constant mainwin = create(Window, "main", 0, 0, 0, 200,200,0) constant AA = create(EditText, "AA", mainwin, 10, 10, 150,20,0) constant BB = create(EditText, "BB", mainwin, 10, 40, 150,20,0) constant CC = create(EditText, "CC", mainwin, 10, 70, 150,20,0) constant DD = create(EditText, "DD", mainwin, 10, 110, 150,20,0) constant WhereTo = {AA,BB,CC,DD} procedure MoveCursor(integer self, integer keyCode) integer shift shift = find(self, WhereTo) if keyCode = VK_DOWN then shift += 1 if shift > length(WhereTo) then shift = 0 end if elsif keyCode = VK_UP then shift -= 1 if shift < 1 then shift = 0 end if else shift = 0 end if if shift > 0 then setFocus(WhereTo[shift]) end if end procedure procedure keyPress(integer self, integer processId, sequence arg) VOID = self VOID = processId if arg[1] = VK_TAB then returnValue(-1) end if end procedure procedure keyDown(integer self, integer processId, sequence arg) integer keyCode, shift VOID = processId keyCode = arg[1] shift = arg[2] if keyCode = VK_TAB then -- make tab same as arrows if and_bits(shift,ShiftMask) = 0 then keyCode = VK_DOWN else keyCode = VK_UP end if end if if keyCode = VK_UP or keyCode = VK_DOWN then MoveCursor(self, keyCode) end if end procedure setHandler(Screen, w32HKeyDown, routine_id("keyDown")) setHandler(Screen, w32HKeyPress, routine_id("keyPress")) VOID = setTabCodes(0) WinMain({mainwin,AA}, Normal)
-- Derek Parnell Melbourne, Australia