
Catching enter key in ListBox

thomas_braun
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?
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 14, 2013 at 04:25 pm - Permalink
thats definitly a step in the right direction. Although I never wanted to edit the cell contents.
Now I have:
With a formerly here posted hack to finish cell editing.
But how can now the listbox get the keyboard focus back?
October 15, 2013 at 02:45 am - Permalink
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
October 15, 2013 at 09:44 am - Permalink
so I'll stick to "." for now.
October 16, 2013 at 12:52 am - Permalink