How to add a menu or Button to Matlab Editor?
조회 수: 4 (최근 30일)
이전 댓글 표시
Has someone any idea how to add a menu to the Matlab Editor? Or how to add a button to the Toolbar of the Matlab Editor? Many thanks.
--- I precise the question: I want to add a customized Menu or Toolbar progammatically. Following Yair Altman's tips http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/ I can add a menu using this code for example:
% Ref: http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/
jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
%jEditor = jDesktop.getGroupContainer('Editor').getTopLevelAncestor;
jEditor = jDesktop.getFrameContainingGroup('Editor');
% MenuBar
jMenuBar=jEditor.getJMenuBar;
jFileMenu=jMenuBar.getComponent(0);
menu = javax.swing.JMenu('SCM');
item = javax.swing.JMenuItem('Check-in/Add');
hitem = handle(item,'CallbackProperties');
set(hitem,'ActionPerformedCallback',@cb_checkin);
menu.add(item);
jFileMenu.add(menu,0);
drawnow
The problem I have now is that the menu is not persistent i.e. disappears when another file is selected. Now I don't know which Editor Callback I shall best overwrite to get the menu created. I've tried 'FocusGainedCallback' but I have to leave the Editor Window to get the menu created. I would like the menu being created if I switch between files in the Editor.
Maybe creating a listener but this is quite a lot for my java undocumented skills. Hope someone may have a solution ready?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!