Clear Filters
Clear Filters

Unexpected number of function input arguments

1 view (last 30 days)
KAE
KAE on 9 Jun 2017
Edited: KAE on 9 Jun 2017
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 Comment
KAE
KAE on 9 Jun 2017
Edited: KAE on 9 Jun 2017
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.

Sign in to comment.

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!