onKeyPress fires for VK_BACKSPACE but not VK_DELETE
- Posted by marky1124 Oct 12, 2009
- 2846 views
Hi,
I've noticed that the w32HKeyPress event fires when the backspace key is pressed but doesn't when the delete key is pressed. This seems inconsistent to me. The documentation says that the event occurs when a "printable" or "visible" key is pressed. I'd have thought that backspace and delete should be treated the same.
I'm using Euphoria v3.1.1 and tested this situation against both win32lib v0.70.04a and v0.70.19.
Here's a little demo to show the symptom. I've coded around it now but I thought it was worth mentioning since it caught me out for a while.
All the best,
Cheers,
Mark
-- code generated by Win32Lib IDE v1.0.4 Build July-06-2008 constant TheProgramType="exw" include Win32Lib.ew without warning -------------------------------------------------------------------------------- -- Window Window1 constant Window1 = createEx( Window, "Demo", 0, Default, Default, 340, 195, 0, 0 ) constant LText6 = createEx( LText, "As you type in the edit box a field below will mention what key you pressed. Notice that pressing DEL doesn't cause that field to update. BACKSPACE does. onKeyPress event doesn't run when DEL pressed", Window1, 20, 20, 304, 64, 0, 0 ) constant LabelEdit3 = createEx( EditText, "", Window1, 88, 100, 48, 20, 0, 0 ) constant PushButton4 = createEx( PushButton, "Close", Window1, 236, 120, 88, 28, 0, 0 ) constant wKey = createEx( LText, "", Window1, 24, 128, 148, 20, 0, 0 ) constant LTextLabelEdit3 = createEx( LText, "Type here --->", Window1, 24, 104, 72, 20, 0, 0 ) --------------------------------------------------------- -------------------------------------------------------------------------------- procedure LabelEdit3_onKeyPress (integer self, integer event, sequence params)--params is ( int keyCode, int shift,int released ) if (params[1] = VK_BACKSPACE) then setText(wKey, "Backspace key pressed") elsif (params[1] = VK_DELETE) then setText(wKey, "DEL key pressed") else setText(wKey, params[1] & " key pressed") end if end procedure setHandler( LabelEdit3, w32HKeyPress, routine_id("LabelEdit3_onKeyPress")) -------------------------------------------------------------------------------- procedure PushButton4_onClick (integer self, integer event, sequence params)--params is () abort(0) end procedure setHandler( PushButton4, w32HClick, routine_id("PushButton4_onClick")) --------------------------------------------------------- WinMain( Window1,Normal )

