Context menu only works in the border around my uitable...
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Patrick Kalita
on 15 Jun 2011
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.
More Answers (1)
Oleg Komarov
on 15 Apr 2011
uh = uicontextmenu;
uimenu(uh,'label','blabla')
t = uitable('Data',magic(10),'uicontextmenu',uh)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!