Is it possible to display a context menu without right click?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In the case that this is no possible, how can I display a menu similar to the uicontextMenu when the user makes a left click on a Figure. 'uimenu' doesn't work because I don't want a bar menu. I just want to display a menu when the user left clicks on a specific place on the figure. Thanks
0 Kommentare
Antworten (1)
Dwight Bartholomew
am 3 Nov. 2016
I had the same issue with a table. Solution was a Java robot. If hTable is the handle for the table then I set up a context menu, for example,
cmenu=uicontextmenu;
uimenu(cmenu,'label','Context Menu #1');
uimenu(cmenu,'Label','Context Menu #2');
uimenu(cmenu,'Label','Context Menu #3');
and assign it to the table with set(hTable,'uicontextmenu',cmenu);
I also have a callback when a cell of the table is selected set(hTable,'CellSelectionCallback',@SelectCell);
Within the SelectCell function, I use a Java Robot to simulate a right-click which initiates the context menu. NOTE - I had to put a 0.2 second pause between "press" and "release" and for anything shorter than 0.2 seconds the system either didn't see the click or was intermittent is seeing the click.
% Simulate a right-click with the mouse
import java.awt.*;
import java.awt.event.*;
mouse = Robot;
mouse.mousePress(InputEvent.BUTTON3_DOWN_MASK);
pause(0.2);
mouse.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
0 Kommentare
Siehe auch
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!