www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/doccp.m
function doccp(h) %DOCCP Determine cut/copy/paste menu enable status % % DOCCP(CGB) determines the correct enable status for the cut, copy and % paste menus. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. if h.GUIExists pNode = h.SelNode; en = {'off', 'off'}; if ~isnull(pNode) node = pNode.info; cpy = cancopy(node); if cpy en{1} = 'on'; end D = mbcutils.Clipboard.paste(); if isempty(D) pst = false; else pst = canpaste(node, D); end if pst en{2} = 'on'; end else cpy = false; pst = false; end mns = [h.Hand.Menubar.Edit.Copy; h.Hand.Menubar.Edit.Paste]; set(mns,{'Enable'},en(:)); % Attach a callback to re-establish enable status when menu is closed. % If the menus are kept disabled, the accelerators will not work. if ~(cpy && pst) bm = xregGui.ButtonUpManager(h.Figure); bm.getNextEvent({@i_restoremenus,mns}); end end function i_restoremenus(~,~,mns) set(mns,'Enable','on');