Newb here, still evaluating Xojo for upcoming project.
I’m trying to enable keyboard navigation in a multicolumn ListBox, specifically the Tab and Enter keys. The ListBox.CellKeyDown event’s Key parameter is only returning 0 for Tab, Enter, arrow keys, etc., thus making it (seemingly - I’m probably doing something wrong) impossible to detect which navigation key the user pressed.
What’s the trick to capturing the actual key that the user pressed? Also, I looked, but couldn’t find any example of editing a ListBox “record” like one would with a true data grid in other programming tools like Delphi, .NET WinForms, etc.
Please post a sample of how you are doing this so we can see what might be wrong
Tab is ChrB(09)
Enter is ChrB(03) or ChrB(13) … Enter and RETURN
Arrows are ChrB(28) to ChrB(31)
BackSpace is ChrB(08)
In the keypressed event
select case details.charCode
case details.keyBackspace, details.keyDelete
Does work for desktop, but not in web.
Thanks - using ChrB() gets me what I need. But John - I don’t see a KeyPressed event, but it looks like that’s because this I’m working on a OSX desktop app, not a web app.
sorry … KeyDown on the desktop
I’m getting an error that says details.charcode does not exist. details is not a parameter for the event, obviously.
The code he posted was obviously cut out of one of his own projects, and neglected to provide the “details” as to what “details” was
Easiest to just use CHRB() in the KEYDOWN event
“Details” is the way WE handles keystrokes. It will probably be back-ported into desktop at some point. The code John posted was web, not desktop. The two hanlde keydown completely different.
Guys, let ask the question another way. Is there some example code or a demo that demonstrates the capturing of all navigation keystrokes in a ListBox for Win/OSX desktop apps?
FUNCTION keydown(key as string) as boolean
SELECT CASE ASCB(key)
''' do what ever the ENTER or RETURN key should do
''' do what ever the TAB key should do
''' handle a backspace
''' handle back arrow
''' handle right arrow
''' handle up arrow
''' handle down arrow
return false ' let OS handle the key, as it is not one you want to handle special
return true ' you handled the key.... OS will ignore it now
Thanks so much - just what I was looking for. Now, for just one more question on this topic: what about Shft-Tab (to go backward)?
Thanks so much - just what I was looking for. Now, for just one more question on this topic: what about Shft-Tab (to go backward)? :)[/quote]
[code]SELECT CASE ASCB(key)
If keyBoard.ShiftKey Then
’ Go back
’ Go Foreward
Thanks Karen. I didn’t know there was a global “intrinsic” object called KeyBoard