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

    function pNotifyButtonUp(obj, Success)
%PNOTIFYBUTTONUP Tell button that a buttonup has occurred
%
%  PNOTIFYBUTTONUP(OBJ, SUCCESS) is used by the toolbar to notify buttons
%  when the user releases the mouse button following a buttondown.  The
%  SUCCESS flag is set to true if the mouse pointer was actually over the
%  button when released and false if the pointer was elsewhere when the
%  button was released.

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


if Success && obj.IsEnabled
    % UDD bug - need to dispatch the event from another udd object
	% to avoid problems with the callback createing a uipushtool
    obj.BooleanState = ~obj.BooleanState;
    % Quietly set the state value to avoid too many redraws
    set(obj.toggletoolListener, 'Enable', 'off');
    a = xregGui.uddDispatcher;
    if obj.BooleanState
        obj.State = 'on';
        set(obj.toggletoolListener, 'Enable', 'on');
        a.send(obj, 'OnCallback',handle.EventData(obj,'OnCallback'));
    else
        obj.State = 'off';
        set(obj.toggletoolListener, 'Enable', 'on');
        a.send(obj, 'OffCallback',handle.EventData(obj,'OffCallback'));
    end
	a.send(obj, 'ClickedCallback',handle.EventData(obj,'ClickedCallback'));
end