Dynamic context menus?
7 ビュー (過去 30 日間)
古いコメントを表示
Is it possible to create a dynamic context menu in a Matlab GUI? For example, I would like to create a context menu with the same look and feel as the one available at the main command line (for example - if you were to type "quad" and then hit tab you would get a list of functions that begin with "quad" like "quad2d" , "quadgk" , ... ). I would like to be able to type something inside of an edit box, hit tab, get the list (in one case their might be 3 matches, but in another there might be 15 matches), arrow up/down to the right one, and select it.
Any hints/clues would be most helpful.
0 件のコメント
回答 (1 件)
Walter Roberson
2011 年 10 月 26 日
Thank goodness I had Lazarus Forms Recovery installed, as I had typed a complete answer only to lose it when the system was taken down for maintenance!
Here goes:
If you use a figure key press function callback then you can detect the tab being pressed. You could then create a popup list or listbox and shift the focus to it. Both popup and listbox allow up/down arrow to move the selection, and allow return to select. You would determine the selected variation, set() the edit box string to that.
Warning: there are known difficulties in using key press callbacks within an edit box. The edit box String property automatic update behavior is weird enough when you have a key press callback that the only practical way to proceed is to remember every keypress yourself under the assumption that the String property will be wrong.
Because of this edit box key behavior, most people who want to change the edit box behavior do so at the JAVA level; for information on that, see http://undocumentedmatlab.com
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!