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

    function show(obj,data)

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

% POPUPMENU\SHOW.  Displays the menu at the current pointer location.
% Usage: obj.show
%        obj.show(data)
% The optional parameter is a cell array, each entry of which becomes an extra
% parameter to the callback function of whichever menu is selected
% by the user, and before that, to the 'onShow' callback associated with this menu.
%
% If an 'onShow' callback is associated with this menu, that function is executed
% before the menu is displayed.  The event data supplied to that function is the
% same as the parameter supplied to this one.
% If the value returned by that function is 0, the menu is NOT shown.


if (nargin==0)
	data={};
end

% get current cursor position
abspos = get(0,'PointerLocation');
fig = get(obj.menu,'Parent');
figpos = get(fig,'Position');
relpos = abspos - figpos(1:2);
obj.callback_data=data;

if ~isempty(obj.onshow)
    cc = {obj.onshow{1},obj,data,obj.onshow{2:end}};
    allow=feval(cc{1:end});
    if allow==0
        return;
    end
end

set(obj.menu,'Position',relpos);
set(obj.menu,'Visible','on');