How do i return focus to text box after pressing pushbutton

Hi, I have a gui with an edit text box and few buttons.... like a calculator...
the edit text box receives input from the keyboard and from the pushbuttons... now the problem is after clicking the pushbuttons, i have to return focus to the edit box manually through the mouse. But i want the cursor to be returned to the edit text box automatically so that i can immediately continue typing after pressing the pushbutton.... can you help?

 채택된 답변

Walter Roberson
Walter Roberson 2016년 9월 11일

0 개 추천

You can call uicontrol() and pass in just the handle of the edit box in order to return focus to the edit box.
However, when you do that, the entire string of the box might be highlighted, so typing anything at that point might replace everything in the edit box.
If you need to position the cursor to a particular location in the edit box, then you are going to need to go in at the Java level and access the properties of the underlying Java Swing control.

댓글 수: 3

Waboraro Olefile
Waboraro Olefile 2016년 9월 12일
편집: Waboraro Olefile 2016년 9월 12일
yes, uicontrol highlights the entire string, which is a problem. I don't know Java, does this mean i have to learn it first? Thanks by the way

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by