0

I am working on a GUI in Matlab using guide. I want the main axes in the GUI to perform a task on left click of mouse and display context menu with the right click. Can we do it in Matlab?

One idea I thought was to recognize mouse clicks and display context menu using a command. Is there a command in Matlab to do this?

Autonomous
  • 8,935
  • 1
  • 38
  • 77
  • [duplicate question](http://stackoverflow.com/questions/14684577/matlab-how-to-get-mouse-click-coordinates) – dlavila May 15 '15 at 19:25

2 Answers2

0

I solved the problem by using the following code in the main axes buttondownfcn callback.

if strcmp( get(handles.figure1,'selectionType') , 'normal')
     myfunction();
end

if strcmp( get(handles.figure1,'selectionType') , 'open')
    mainaxes_contextmenu.Visible = 'on';
end
-1

All your questions are possible in Matlab. To create context menus programmatically you can read more here.

If you are using GUIDE, then you can create the context menus under Tools / Menu Editor / Context Menus as well as the corresponding callback functions.

By the way, you should use this perfect tool at first, there are tons of examples there!!!

scmg
  • 1,904
  • 1
  • 15
  • 24