How to control mouse pointer?

if value is left go left.
if value is right go right.
if value is rest stop pointer in its current position or bring back to center.
This in a loop would be great.

5 件のコメント

Walter Roberson
Walter Roberson 2019 年 10 月 31 日
You can set the axes CurrentPoint property. You will need to keep track of the current location and adjust it, as the underlying mechanism has no idea what "go left" means.
CalebJones
CalebJones 2019 年 10 月 31 日
編集済み: CalebJones 2019 年 10 月 31 日
Can you provide some sort of pseudocode?Walter Roberson
Walter Roberson
Walter Roberson 2019 年 10 月 31 日
ax = handles.axis1;
xy = handles.xy;
if strcmp(value, 'left')
xy = xy - [10 0];
elseif strcmp(value, 'right')
xy = xy + [10 0];
else
xy = handles.xy_init;
end
handles.xy = xy;
set(ax, 'CurrentPoint', xy);
guidata(hobject, handles)
CalebJones
CalebJones 2019 年 10 月 31 日
Undefined variable "handles" or class "handles.axis1".
Error in mouse (line 1)
ax = handles.axis1;
Walter Roberson I'm getting this error
Walter Roberson
Walter Roberson 2019 年 10 月 31 日
It is pseudocode.
In particular, the expected context is that the code would be in a callback in a GUIDE created GUI, and that you had created an axes with tag 'axis1' that is the axes the cursor position is to move in. The code also assumes that you have stored an xy pair of the rest position in handles.xy_init and that you have previously initialized handles.xy to handles.xy_init

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2019 年 10 月 31 日

コメント済み:

2019 年 10 月 31 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by