- WindowButtonMotionFcn:- https://in.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-WindowButtonMotionFcn
- CurrentPoint:- https://in.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html#budumk7-CurrentPoint
Detect mouse position over embedded plot in live script.
13 ビュー (過去 30 日間)
古いコメントを表示
I just started using live scripts. Now I am trying to figure out if I can detect mouse position over an embedded plot.
I tried using callback functions and events with the embedded figures, without much luck so far. Here's a non-working example of what I am trying to do:
hfig = figure();
plot(axes('Parent', hfig), rand(5));
hfig.WindowButtonMotionFcn = @(src,evt)disp(src);
This displays a plot inline and I was hoping that when I move the mouse pointer over the plot, the `src` object would be printed out. That does not happen. If I click 'Open in figure window' and then move the mouse over the figure, the callback starts firing.
Is there any way to get callback functions or other events to to work in live scripts. Or is there some other way to read out mouse position in embedded plots?
0 件のコメント
回答 (1 件)
Ravi
2023 年 10 月 4 日
Hi DNF,
According to my understanding, you have a plot on which you want to record the cursor position as your mouse pointer is hovered on the figure.
The figure object has a callback function, “WindowButtonMotionFcn” that triggers when the cursor is hovered on the figure.
Now the objective is to print the position of the cursor every time it is moved. The axes object has a property, “CurrentPoint” that gives the current position of the cursor. The callback function can be written in such a way that the position is printed using the “CurrentPoint” property of the axes object.
For more information, kindly refer to the below links.
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!