how to implement "Evaluate or Open Code You Select" in everywhere?

Asked by HaveF on 17 Aug 2012
Latest activity Commented on by HaveF on 19 Aug 2012

I want to implement(and add some features to) the function "Evaluate Selections" where you select your code and click you right mouse.

In editor, I can do this:

editorObject = matlab.desktop.editor.getActive;
eval([editorObject.SelectedText ';']);

but in command window, help window, how can I do that?

0 Comments

HaveF

Tags

Products

1 Answer

Answer by Jan Simon on 18 Aug 2012
Edited by Jan Simon on 19 Aug 2012
Accepted answer

You can't.

[EDITED]

Expanding the GUI capabilities of Matlab's user-interface is possible with undocumented and unsupported methods. But it is likely, that different methods are needed for different Matlab versions. Therefore the next update would make all your work useless or could even cause severe bugs.

It seems to be more promising, if you create a dedicated function, which evaluates code, which is copied into the clipboard. The needs 2 or 3 additional mouse clicks, but does not depend on the Matlab version.

1 Comment

HaveF on 19 Aug 2012

Thank for your reply. Or, can I get the java code of right-click menu(Evaluate Selection)? Something like Yair Altmam's undocumented Matlab?

Jan Simon

Contact us