Context menu only works in the border around my uitable...

2 ビュー (過去 30 日間)
David
David 2011 年 4 月 15 日
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

採用された回答

Patrick Kalita
Patrick Kalita 2011 年 6 月 15 日
I think the unsatisfying answer here is that it's just a bug. Here's the bug report.
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 件のコメント
David
David 2011 年 6 月 15 日
Well, at least that confirms that I am not crazy. ;-)
I am going with a slight redesign of the GUI that substitutes menu bar menus for the context menus. Not a big inconvenience but a future fix would be welcomed.
Thanks.

サインインしてコメントする。

その他の回答 (1 件)

Oleg Komarov
Oleg Komarov 2011 年 4 月 15 日
uh = uicontextmenu;
uimenu(uh,'label','blabla')
t = uitable('Data',magic(10),'uicontextmenu',uh)
  1 件のコメント
David
David 2011 年 6 月 15 日
This really didn't solve my problem, so much as it confirmed that the problem extends to other arbitrary tables. The context menu still does not work inside the table. It only appears if I right-click in a thin border around the table.
Let me add that I am running Matlab2010b on MacOSX 10.6.7.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by