www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcmultiview/@ToggleAction/createToolbutton.m

    function hButton = createToolbutton(obj, hParent)
%CREATETOOLBUTTON Create a toolbar button for the action
%
%  HBUTTON = CREATETOOLBUTTON(OBJ, HPARENT) creates a new toolbar button
%  for the action.  When the button is clicked the action will execute.

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


hButton = xregGui.uitoggletool(hParent, ...
    'ClickedCallback', {@i_execute, obj}, ...
    'TransparentColor', [0 255 0]);
obj.setToolbuttonProperties(hButton);

% Attach a listener to keep menu state matching the action
StateList = handle.listener(obj, 'StateChanged', {@i_resetbutton, hButton});
set(hButton, 'UserData', StateList);


function i_execute(src, evt, obj)
obj.Selected = strcmpi(src.State, 'on');
obj.execute;

function i_resetbutton(obj, evt, hButton)
obj.setToolbuttonProperties(hButton);