Why are datatips editable?

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.

 Respuesta aceptada

Adam Danz
Adam Danz el 19 de Jun. de 2023
Editada: Adam Danz el 19 de Jun. de 2023

0 votos

> 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 comentarios

Adrian
Adrian el 20 de Jun. de 2023
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 el 20 de Jun. de 2023
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 el 20 de Jun. de 2023
@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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Etiquetas

Preguntada:

el 14 de Jun. de 2023

Comentada:

el 20 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by