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
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 Exchange에서 Creating, 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