How to change the cursor
이전 댓글 표시
I have a gui form and there're axes.
When the graph has built in the axes by plot(), is it possible to set the cursor at the position of the last point of the graph?
Thank you.
댓글 수: 7
Jan
2018년 2월 4일
There is no "cursor" in axes objects- So please mention, what you mean.
per isakson
2018년 2월 4일
편집: per isakson
2018년 2월 4일
Doc says: PointerLocation — Current location of pointer, specified as a two-element vector of the form [x y]. ... Move the pointer by changing the values of this property.
@Jan, You are correct, the text is copied from Root Properties, Graphics environment and state information. (I removed the string "[Figure.]" to avoid causing more confusion.)
Furthermore, it takes some programming to use PointerLocation to "to set the cursor at the position of the last point of the graph".
Jan
2018년 2월 4일
@per: Ah, the position of the mouse cursor. But which documentation mentions "[Figure.]PointerLocation"? The groot object has such a property, but not the figures.
Image Analyst
2018년 2월 4일
It's not easy but it can be done with java.robot. Moving the mouse is trivial enough - it's the determining where on the screen that the last data point was plotted that is the hard part.
Walter Roberson
2018년 2월 4일
The figure property is named CurrentPoint
Jan
2018년 2월 4일
@Image Analyst: getpixelposition helps.
Jan
2018년 2월 4일
@Kirill: It is still not clear, which "cursor" you mean.
답변 (1개)
Image Analyst
2018년 2월 4일
Here's some code to get you started with Java Robot:
import java.awt.Robot
import java.awt.event.*
mouse = Robot;
plot(1:10, 'bo-', 'LineWidth', 2);
grid on;
% ResetZoom(mouse);
% Reset the zoom so that the links will be at the same place every time.
y = 500
for x = 500 : 50 : 700
fprintf('x = %d, y = %d\n', x, y);
mouse.mouseMove(x, y);
% Set a breakpoint on the next line and wiggle your mouse to see if it put it in the right place.
% % Press the mouse button.
% mouse.mousePress(InputEvent.BUTTON1_MASK);
% mouse.mouseRelease(InputEvent.BUTTON1_MASK);
pause(0.5); % Wait at that spot for user to see it.
end
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!