How can I use WindowButtonMotionFcn in an app?
62 views (last 30 days)
Show older comments
Greetings!
I am exploring the app designer and attempting to create GUI for a script which I use frequently. The script is not something I wrote, I borrowed it from the FileExchange (PlotDigitizer).
I have managed to create the app layout and add callbacks and code to load the image and calibrate the plot axes. However, the code relies on WindowButtonMotionFcn to track the mouse pointer and for whatever reason, after the image is loaded, anytime the cursor hovers over the plot I get an error that says:
"Undefined function 'Get_Mouse_Location' for input arguments of type 'matlab.ui.Figure'.
Error while evaluating Figure WindowButtonMotionFcn."
I believe the code responsible for this starts at line 110, but I am at a loss as to why, although, I won't be surprised if it's something simple which I overlooked.
% Get mouse location
set(gcf, 'WindowButtonMotionFcn', @Get_Mouse_Location);
m_location = Get_Mouse_Location(app);
There is far too much code to post, so I have attached it instead. If anyone is up for helping me troubleshoot this so I can understand my mistake (and learn from it!), I would appreciate it.
Thanks in advance,
-Matt
PS - It might help if you tried PlotDigitizer first to understand how the script works, although, if you work from the app... Click Load Image first, locate and load the included plot. The errors will start popping up at that point.
0 Comments
Accepted Answer
Kevin Holly
on 10 Aug 2022
Matt,
I cleaned up your code and changed the Get_Mouse_Location callback in line 110 (see attached). I got rid of the global variables as they are not needed.
More Answers (1)
See Also
Categories
Find more on Annotations 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!