Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
David
David am 15 Apr. 2011
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

Akzeptierte Antwort

Patrick Kalita
Patrick Kalita am 15 Jun. 2011
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 Kommentar
David
David am 15 Jun. 2011
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Oleg Komarov
Oleg Komarov am 15 Apr. 2011
uh = uicontextmenu;
uimenu(uh,'label','blabla')
t = uitable('Data',magic(10),'uicontextmenu',uh)
  1 Kommentar
David
David am 15 Jun. 2011
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by