Context menu only works in the border around my uitable...
2 ビュー (過去 30 日間)
古いコメントを表示
Using GUIDE I built a GUI containing a uitable, and I associated a context menu with the uitable. When I run the GUI, the context menu only appears when I right click in a very narrow perimeter around the table, not when I right click in the area comprising the rows/cells of the table. I do not have a ButtonDownFcn set for the uitable, and I have tried (perhaps erroneously) to rectify the observed problem by setting HitTest for the uitable to 'off'. Didn't work. My goal is to be able to use the left mouse button for selecting a cell (I know how to do this from previous work) and the right mouse button for calling the context menu to operate on the cell, but this is impractical if the context menu only works in a thin strip outside the uitable. Bear in mind here that I don't need to know how to get cell-specific data from a right-click; I just want the context menu to work within the space of the table. What am I missing?
Rapid Summary: The context menu associated with my uitable doesn't work within the table, only in a small perimeter around it. How can I make it work inside the table too?
Thanks to everyone who gives this a look.
David
0 件のコメント
採用された回答
Patrick Kalita
2011 年 6 月 15 日
It appears you can work around the issue by setting the uitable's Enable property to anything but 'on'. Check this out:
uicm = uicontextmenu;
uimenu('Label', 'foo', 'Parent', uicm);
uitable('Data', magic(5), 'uicontextmenu', uicm, 'Enable', 'inactive')
Although based on your description, it sounds like setting the Enable property to 'inactive' or 'off' is not be feasible in your application. Unless maybe you had a button on the UI itself that toggled the Enable state of the table... that seems kind of yucky.
その他の回答 (1 件)
Oleg Komarov
2011 年 4 月 15 日
uh = uicontextmenu;
uimenu(uh,'label','blabla')
t = uitable('Data',magic(10),'uicontextmenu',uh)
参考
カテゴリ
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!