Getting cell name from listbox when using keyboard arrow keys and enter/return.

OK, so I’ve got a listbox that has a list of directories. Using doubleclick along with the combination of cellclick with “'cellName = me.cell(row, column)”, I can successfully double click on the directory name in the cell and pop open the full path in Windows Explorer (the directories in the list box are the last directories in the path). I’m trying to accomplish the same thing when you tab into the listbox and move up and down with the arrow keys. I want to be able to hit return/enter and pop open the whole path, just like with the mouse. I’ve got the return/enter key portion working, but it never grabs the cell name which contains the last directory in the path. Windows explorer is always one directory up from where I want it. I’ve tried using “'cellName = me.cell(row, column)” in the event handlers where I thought they might work, like cellgotfoucs, keycelldown, keylostfocus, and celltextchange. None of these work at getting the cell name, as they did with the mouse and cellclick.

So to sum it up, everything is working except grabbing the cell name when using the arrow keys to select a cell.

I’m sure it’s something simple I’m overlooking. This is the first time I’ve tried to do this with the keyboard.

Try this in your KeyDown event and watch the message log:

system.DebugLog(me.SelectedRowValue)

Or simply store the FolderItem into Cell Tag (search Tag in the documentation) and use that instead of rebuilding one with the CellName…

OK, I put it in. Where’s the message log?

I don’t know what that means.

Or for API1 use

system.DebugLog(me.cell(me.ListIndex,0))

or use the tag as Emile mentions, it depends if you show the user the path in the listbox or if you want to keep it hidden “behind the scenes”.

on the bottom of the IDE window

[quote=473970:@]

on the bottom of the IDE window[/quote]

Got it. So, it shows each cell (directory) as I scroll down the list…but nothing different when I choose the final cell.

As of right now, I don’t have “cellName = me.cell(row, column)” in any of the event handlers that I mentioned earlier. Should I try each one with this enabled and see what shows up in the log?

It sounds like the issue you have is that message is triggering on cursor presses when you want it to only trigger on Enter, try this in the KeyDown event

If key = chr(13) Or key = chr(3) Then '13 = enter and 3 = numpad enter system.DebugLog(Me.SelectedRowValue) End If

[quote=473972:@]It sounds like the issue you have is that message is triggering on cursor presses when you want it to only trigger on Enter, try this in the KeyDown event

If key = chr(13) Or key = chr(3) Then '13 = enter and 3 = numpad enter system.DebugLog(Me.SelectedRowValue) End If [/quote]

That’s it! I ditched tying the “cellName = me.cell(row, column)” to an event handler (although this worked with the mouse) and used “Me.SelectedRowValue” instead right in the keydown portion where I link the various fields together to form the whole path.

Thank you, Julian!

Also, thanks for showing me the message log. I had only used “break” up till now!

You can store FolderItems directly into Row or Cell. Why do you want to build one taking a default location (not shared in the op) and the name stored in a Cell ?

Look in ListBox LR and search for Tag. If you do not understand, get an eye on the LR as I wrote, or forget this entry.

Read:
http://documentation.xojo.com/api/deprecated/listbox.html#listbox-celltagat

This allows you to store what you want (here, a FolderItem) into that location for the Cell Contents).