I created a custom datatip using a DataTipTemplate for a plot line, but when I click on the datatip I can edit the string and change it for future datatips.
I can't find any "Editable" property for the datatip.
Is there a way to stop people editing the datatip text?
  • Please don't reply with an AI generated answer that hasn't been checked. I can do that if I wanted to. I posted here to get advice from people who have used this feature before and know what they are talking about.

 採用された回答

Adam Danz
Adam Danz 2023 年 6 月 19 日
編集済み: Adam Danz 2023 年 6 月 19 日

0 投票

> Is there a way to stop people editing the datatip text?
There is no way to turn off the option for users to manually edit the datatip.
If you're using the datatip function to add a datatip, you could set the DataTip object's HitTest to off to prevent all interactions with the datatip including accessing the right-click context menu and toggling the datatip off ⚠️.
d = datatip(h,x,y);
d.HitTest = 'off';

3 件のコメント

Adrian
Adrian 2023 年 6 月 20 日
Thanks @Adam Danz
That does prevent the datatip from being edited. but it also stops the datatip from being removed.
Previously clicking a point would display the datatip and clicking it again would remove it. Now they just accumulate. Is there other code I need to remove datatips?
Regards
Adrian
Adam Danz
Adam Danz 2023 年 6 月 20 日
Yes, I mentioned this in my answer 🙂. The HitTest workaround is not ideal.
You can remove all datatips in figure fig programmatically using
delete(findobj(fig,'type','DataTip'))
Adrian
Adrian 2023 年 6 月 20 日
@Adam Danz Yes I did see that caveat in your answer (after I posted my reply).
I've raised the issue with Matlab support, maybe an editable property could be added to datatips in future. Seems strange to allow all kinds of controls on the right click and editing with the left click by default with no way to turn them off.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

リリース

R2022b

タグ

質問済み:

2023 年 6 月 14 日

コメント済み:

2023 年 6 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by