Catching enter key in ListBox

Hello,

I have ListBox which does something on doubleclick. Now I would like to be able to complete control the ListBox using the keyboard.
But I'm not able to check if the user pressed the enter key on an entry.

Minimal example:
Function doStuff()
   
    Make/T/O/N=5 list
    list = "text " + num2str(p)
    NewPanel/K=1
    ListBox list1, proc=listBoxProc,listWave=list, size={150,150}, mode=1
End

Function listBoxProc(lba) : ListBoxControl
    STRUCT WMListboxAction &lba

    Variable row = lba.row
    Variable col = lba.col
    WAVE/T/Z listWave = lba.listWave
    WAVE/Z selWave = lba.selWave

    switch( lba.eventCode )
        case -1: // control being killed
            break
        case 1: // mouse down
            break
        case 3: // double click

            if(!WaveExists(listWave) || row >= DimSize(listWave,0))
                return 0
            endif

            printf "row: %d\r", row
       
            break
        case 12: // keystroke
            if(!WaveExists(listWave))
                return 0
            endif

            printf "pressed key: %d\r", row
            break
        case 13: // checkbox clicked (Igor 6.2 or later)
            break
    endswitch

    return 0
End


Currently I use the "." (ASCII 46) as workaround but that is kind of uninutitive.

Any ideas?
Thanks John,

thats definitly a step in the right direction. Although I never wanted to edit the cell contents.

Now I have:
Function doStuff()

    DoWindow/K Panel0
 
    Make/T/O/N=(5,1) list
    Make/U/B/O/N=(5,1,2) sel
    sel[][0] = 0x02

    // override edit color 
    Make/O/W/U/N=(5,3) myColors = 65535
    SetDimLabel 2, 1, backColors, sel

    list = "text " + num2str(p)
    NewPanel/K=1
    ListBox list1, proc=listBoxProc,listWave=list, size={150,150}, mode=1, selWave=sel, colorWave=myColors
End
 
Function listBoxProc(lba) : ListBoxControl
    STRUCT WMListboxAction &lba
 
    Variable row = lba.row
    Variable col = lba.col
    WAVE/T/Z listWave = lba.listWave
    WAVE/Z selWave = lba.selWave
 
    switch( lba.eventCode )
        case -1: // control being killed
            break
        case 1: // mouse down
            break
        case 3: // double click
 
            if(!WaveExists(listWave) || row >= DimSize(listWave,0))
                return 0
            endif
 
            printf "row: %d\r", row
 
            break
        case 6: // begin edit
            print "begin edit aka pressed enter the first time"
            // forcefully end cell editing
            ListBox list1,disable=1
            ListBox list1,disable=0
            // how to get the focus onto the ListBox back ?
            break
        case 7: // end edit
            print "end edit aka pressed enter again after begin edit"
            break
        case 6: // keystroke
            if(!WaveExists(listWave))
                return 0
            endif
 
            printf "pressed key: %d\r", row
            break
        case 13: // checkbox clicked (Igor 6.2 or later)
            break
    endswitch
 
    return 0
End


With a formerly here posted hack to finish cell editing.
But how can now the listbox get the keyboard focus back?
Ah- your listbox is not being edited.

A check of the sourcecode indicates that you will never get the return key while the listbox has keyboard focus. Someday maybe we can address this issue- it's actually one that I have faced myself.

A window hook function will get the keystroke, but only when the listbox does not have keyboard focus.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com