1

I found a neat bit of code for setting drawing tools via callback:

draw.m .

Edit

My apologies - I didn't realize that the Name property was a red herring - it is the annotation call that enables drawing the various figures.
So my corrected question is: is there a way to execute other menu item commands, such as set(gcf,'Some_property','Rotate 3D') ?

Community
  • 1
  • 1
Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73

1 Answers1

4

The easiest way to execute a menu item's command is to get a handle to the menu item and then inspect the Callback property to see what it calls internally.

rotate_menu = findall(gcf, 'type', 'uimenu', 'tag', 'figMenuRotate3D');
rotate_menu.Callback

%   'toolsmenufcn Rotate'

As you can see this uses an internal function toolsmenufcn which we could call directly to activate the tool.

toolsmenufcn(gcf, 'Rotate')

If you actually look at the contents of toolsmenufcn.m (edit toolsmenufcn), you will see a list of all available commands.

Using the toolsmenufcn directly is of course undocumented so use at your own risk. On the other hand, dynamically retrieving and executing the Callback for the menu should work across versions.

Suever
  • 64,497
  • 14
  • 82
  • 101