How to determine cursor position in 'edit' uicontrol

11 vues (au cours des 30 derniers jours)
Armindo
Armindo le 2 Mar 2016
Commenté : Juan Ruiz le 2 Avr 2023
I have an application where there are several buttons that apply a specific function to the data. The user can also enter values in the edit box. However if the cursor is positioned in the edit box and a button is pressed the new function will apear at the end of the edit box and I need that this appear at cursor position how to do this?

Réponse acceptée

Adam
Adam le 2 Mar 2016
Probably you would have to get the 'CurrentPoint' from the figure and compare this against the 'Position' property of the edit box. If the edit box is parented by some panel inside the figure then you would have to go a layer deeper and get the position of the panel and then the position of the edit box within the panel.
Since you would presumably need to test this a lot you can obviously calculate the position of the edit box relative to the figure (if it is inside a parent panel) and store it so that you can test the 'CurrentPoint' against it quickly.
In terms of actually putting text at a specific location within an edit box though I don't think this is possible (maybe using java) as you just set the 'String' property of the edit box and do not have control over its positioning within the edit box.
  1 commentaire
Juan Ruiz
Juan Ruiz le 2 Avr 2023
Hi, I would like to know if there's a better way to do this on 2023. I'm using matlab app designer and I'm trying to insert text at the position of the cursor on a EditField by pushing a button. @Armindo and @Adam

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by