www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@popupmenu/enableitems.m

    function enableitems(obj,array)

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.

% POPUPMENU\ENABLEITEMS. Sets the enabled/disabled
% state of all menu items.
%
% Usage: obj.enableitems(array)
%
% Parameter is a cell array of strings of the same
% length as class member 'items'.  Each string must
% be 'on' or 'off' depending on whether the menu
% item is to be available or 'greyed-out'.


len=length(obj.submenus);
if length(array)~=len
	error(message('mbc:xregGui:popupmenu:InvalidSize'));
end

set(obj.listener,'enabled','off'); % we don't need the listener
                                   % because we set the menu state manually.
for k=1:length(obj.submenus)
	set(obj.submenus(k),'Enable',array{k});
	obj.items(k).enabled=array{k};
end
set(obj.listener,'enabled','on');