2

I would like to place the cursor (or even better highlight the text) in an Edit text box in a Matlab GUI when the application starts, is there any simple way of doing this?

Thanks in advance!

  • simple way: no. maybe possible workaround: [I once had a similar problem](http://stackoverflow.com/questions/19399701/how-to-pre-set-cursor-or-selection-for-default-answer-in-input-dialog) – Robert Seifert Nov 18 '13 at 17:55
  • @thewaywewalk i just found something, that could help: http://www.mathworks.com/matlabcentral/newsreader/view_thread/80041#204096 – Lucius II. Nov 19 '13 at 15:59
  • ok, not possible to use with newer version of matlab :( – Lucius II. Nov 19 '13 at 16:08

1 Answers1

1

You'll need this tool from Yair Altman http://www.mathworks.co.uk/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects

and than just type following:

jEdit = findjobj(HandleOfYourEditBox);
jEdit.Caret.setDot(0)

To highlight text use following:

jEdit.selectAll % to highlight everything
jEdit.setSelectionStart(3) % start Index
jEdit.setSelectionEnd(4)  % end Index
GavriYashar
  • 345
  • 1
  • 3
  • 10