Using WindowButtonDownFcn callback to track mouse moves in figure
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In Matlab 2013a I must track mouse moves in a figure to let user position vertical markers (timeline limits).
After creating my figure with hfig = figure('Position',rect, ...
I call set(hfig,'WindowButtonDownFcn',@ButtonDown);
and declare
function ButtonDown(hObject, eventdata, handles)
But when I click the mouse in the figure, I get "Undefined function 'ButtonDown' for input arguments of type 'double'. Error while evaluating figure WindowButtonDownFcn".
What is the right function prototype for this callback?
0 Kommentare
Antworten (1)
Geoff Hayes
am 8 Jun. 2016
Luc - the correct signature for this function would be
function ButtonDown(hObject, eventdata)
since you are not supplying any additional parameters when you assign this callback to the WindowsButtonDownFcn
set(hfig,'WindowButtonDownFcn',@ButtonDown);
However, I suspect that isn't the source of the error. Where is this function, ButtonDown, defined relative to your function that assigns it as a callback? Are they both in the same file?
4 Kommentare
Geoff Hayes
am 8 Jun. 2016
Luc's answer moved here
Yes, the figure is created programmatically.
Thanks for the answer.
Rik
am 3 Nov. 2017
If you are not nesting functions, you can use guidata as well to access the handles struct.
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!