Unexpected number of function input arguments

1 次查看(过去 30 天)
I am confused by "extra" function inputs in the program GUI_27 from the file exchange. Can you help me figure out where they come from? Here's the relevant lines,
% Here we pass in 1 argument, S, to a function accessed by the handle @fh_wbmfcn.
set(S.fh,'windowbuttonmotionfcn',{@fh_wbmfcn,S})
% Here is the start of function fh_wbmfcn which receives 1 argument in the line above
function [] = fh_wbmfcn(varargin)
% Yet when I put a breakpoint at this point to check, there were 3 inputs!
% varargin{1} is a handle to a figure that fh_wbmfcn will access, which we didn't pass in above
% varargin{2} is mouse data within that figure, which we didn't pass in above
S = varargin{3}; % The third argument is the structure S passed in above
I am confused why 3 inputs appear within fh_wbmfcn when it seems we only passed in 1 input. How did the other 2 inputs get in there?
  1 个评论
KAE
KAE 2017-6-9
编辑:KAE 2017-6-9
Walter's answer here indicates that these 2 additional inputs are expected because this is a graphics object callback. I do not know how to give him credit for the fact that his answer addressed the present question, but will leave this question up since it might help someone. If instead I should delete it, please let me know.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by