How to disable text search in list box?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a GUI I'm working on. The figure keypressfcn moves data around when you press a number on the keyboard. I also have a listbox uicontrol in the figure. The list items all start with numerals. When the listbox has focus, pressing a number key changes which item is selected in the listbox. This is not desired. I also set the listbox keypressfcn to be identical to the figure keypressfcn. The result is that pressing a number key when the listbox has focus moves the data around and changes which item is selected in the listbox. This causes errors because which listbox item is highlighted determines how data are plotted, and I get size mismatch errors when trying to move data during the figure keypressfcn call.
I want to disable the behavior that pressing a key when the listbox has focus changes the listbox selection to the first item starting with that character.
My hunch is that something in the undocumented Java object underlying the listbox uicontrol is what I need to hack into. I do not have a lot of experience with Java. I can get access to the UIscrollPane using scrollPane = findjobj(myListboxHandle), and I can get access to a JList object via get(scrollPane.getViewport(),'view') [or something like that - there might be an additional 'getAccessibleContent' call that I was using]. But I'm not sure where to go from there. I've checked the input and action maps for the jList object using getInputMap and getActionMap and they're both empty. The keybindings also seem to be empty. The only registered keystrokes are arrow keys. I'm not sure where this 'searching' behavior is being instantiated. Is it in some basic UI package or something? I'm stuck.
If anyone out there has more experience with hacking the MATLAB java objects, your insights would be greatly appreciated. Or maybe I'm barking up the wrong tree with the Java angle. If so, please set me straight. I've also tried some workarounds, but it seems like the 'character search' function and my own keypressfcn are racing each other, and sometimes the search happens first and sometimes my own keypressfcn happens first... which makes the whole thing even more mystifying for me, and prevents me from coming up with a stable workaround.
Here's a little example showing what I mean (much much simpler than what I'm really doing), in theory, whenever I press a key, this thing should plot the same 1x10 vector of data, but if the listbox has focus, sometimes it plots a 1x11. If you keep pressing '1' and '2' keys, you can see how it's a little random whether the keypressfcn or the search function happens first (or at all).
if true
data = {rand(1,10),rand(1,11)};
fh = figure('keypressfcn','plot(ax,data{get(lb,''value'')})');
ax = axes;
lb = uicontrol(fh,'keypressfcn',get(fh,'keypressfcn'),'string', {'1','2'},'style','listbox');
end
I'm using MATLAB 7.13.0.564 64-bit on 64-bit Windows 7 Enterprise SP1.
Thanks in advance for any help you can provide.
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!