Text beside the pointer in ginput

8 ビュー (過去 30 日間)
Timon Rayis
Timon Rayis 2020 年 7 月 20 日
コメント済み: Timon Rayis 2020 年 7 月 21 日
Can we put some text beside the pointer when ginput is enabled? something like this:
so that the text also moves along with the pointer until the mouse button press or enter/return key is pressed?

採用された回答

Adam Danz
Adam Danz 2020 年 7 月 20 日
編集済み: Adam Danz 2020 年 7 月 20 日
No can do.
The ginput function suspends all interactive properties of a figure window so even if a WindowsButtonMotionFcn function were written to continuously update the position of a text object to follow the cursor, the ginput function will temporarily disable it while in use.
You could, however, include the text instructions in a stationary position.
Example:
% Create demo figure
fig = clf();
ax = axes(fig);
% Place text in upper, right corner of axes.
tx = text(max(xlim(ax)), max(ylim(ax)), 'Select point 1', ...
'HorizontalAlignment', 'right', 'VerticalAlignment', 'Top', ...
'Color', [0 0 .80, .5], 'BackGroundColor', [.27 .51 .70, .5], ...
'FontSize', 14, 'FontWeight', 'Bold');
% Get point 1
[x(1),y(1)] = ginput(1);
% Update text
tx.String = 'Select point 2';
% Get point 2
[x(2),y(2)] = ginput(1);
% Remove text
delete(tx)
  1 件のコメント
Timon Rayis
Timon Rayis 2020 年 7 月 21 日
Good alternative. Many thanks :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by