www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcmultiview/@ToggleAction/createButton.m
function hButton = createButton(obj, hParent) %CREATEBUTTON Create a uicontrol button for the action % % HBUTTON = CREATEBUTTON(OBJ, HPARENT) creates a new button for the % action in the given parent. When the button is clicked the action will % execute. % Copyright 2005-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. hButton = uicontrol('Parent', hParent, ... 'Style', 'togglebutton', ... 'Callback', {@i_execute, obj}); obj.setButtonProperties(hButton); % Attach a listener to keep state matching the action StateList = handle.listener(obj, 'StateChanged', {@i_resetbutton, hButton}); set(hButton, 'UserData', StateList); function i_execute(src, evt, obj) obj.execute; function i_resetbutton(obj, evt, hButton) obj.setButtonProperties(hButton);