How to change the cursor
Afficher commentaires plus anciens
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 commentaires
Jan
le 4 Fév 2018
There is no "cursor" in axes objects- So please mention, what you mean.
per isakson
le 4 Fév 2018
Modifié(e) : per isakson
le 4 Fév 2018
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
le 4 Fév 2018
@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
le 4 Fév 2018
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
le 4 Fév 2018
The figure property is named CurrentPoint
Jan
le 4 Fév 2018
@Image Analyst: getpixelposition helps.
Jan
le 4 Fév 2018
@Kirill: It is still not clear, which "cursor" you mean.
Réponses (1)
Image Analyst
le 4 Fév 2018
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
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!