How to determine cursor position in 'edit' uicontrol
조회 수: 17 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!