I have in Keydown in a Listbox and the beginning line of the code is
If Asc(key) = 13 Or Asc(key) = 3 then
For some reason this line’s breakpoint isn’t breaking unless I hit the enter key twice.
The listbox has focus, and no control on the window is default.
Suggestions?
My guess is that you are editing a cell at the time. So the first time the enter key is hit it is being processed by the cell’s EditCell routine to tell the cell that editing is finished. I don’t know if it will help you but you might want to look at the Keyboard.AsynckeyDown which will read the keyboard rather than waiting for the listbox cell to process it.
Sorry but Async didn’t work. I like the idea though.
If Keyboard.AsyncKeyDown(&h24) Or Keyboard.AsyncKeyDown(&h4c) Then
Interesting though is the debugger still thought I was using Chr(13).
Edit: Could it have something to do with Listbox.Selected(row)?
I notice the selection highlights change.
Try putting the calls to Keyboard.AsyncKeyDown in the listbox’s Change event. Maybe that’ll let it get caught the way you need.
Are you in an “edit box” on the listbox when you press enter?
As Dale said, your first enter is completing the cell edit, then the second enter is firing on KeyDown.
If this is the case, then you need to put your IF inside the event CellKeyDown
KeyDown is for when you aren’t editing the cell.
Thank you. It’s sometimes very confusing which event to put stuff in.
It might help to think the the textedit as a separate control. (It really is) That’s why it has separate mouse, keyboard, and focus events. The texts is referenced like listbox.activecell.text
rather than listbox.cell
https://forum.xojo.com/40351-listbox-cellkeydown-issue