How can I use WindowButtonMotionFcn in an app?
67 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Kevin Holly
2022-8-10
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!