Re: Win32Lib Losing Keys
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jul 08, 2004
- 491 views
I couldn't remember this last night, or where I've used it, but I did this morning, so my apologies - Derek has meantime suggested a bunch of changes to win32lib which I am studiously ignoring The following trick will allow the user to deliberately tab to a control and press space to click it, but then the button loses focus and 'normal' keyboard handling resumes, which is probably better than an outright ban on space activating a button. To be honest, the spacebar both activates the button AND appears on the statusbar, so a further small tweak may be required. procedure Window1_onKeyPress (integer self, integer event, sequence params)--params is ( int keyCode, int shift ) setText(StatusBar2, "Got key " & params[1] & "." ) if self=PushButton4 then setEnable(PushButton4,False) setFocus(Window1) setEnable(PushButton4,True) end if end procedure setHandler( {Window1,PushButton4}, w32HKeyPress, routine_id("Window1_onKeyPress")) integer numclicks numclicks=0 procedure PushButton4Click(integer self, integer event, sequence params) numclicks+=1 setText(Window1,sprint(numclicks)) setEnable(PushButton4,False) setFocus(Window1) setEnable(PushButton4,True) end procedure setHandler(PushButton4,w32HClick,routine_id("PushButton4Click"))