How to determine cursor position in 'edit' uicontrol

조회 수: 17 (최근 30일)
Armindo
Armindo 2016년 3월 2일
댓글: Juan Ruiz 2023년 4월 2일
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?

채택된 답변

Adam
Adam 2016년 3월 2일
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
Juan Ruiz
Juan Ruiz 2023년 4월 2일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by