How to determine cursor position in 'edit' uicontrol
23 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Adam
on 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 Comment
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!