How can put or place cursor a tex edit box in GUI without a mouse click?

2 ビュー (過去 30 日間)
Tevfik YILMAZ
Tevfik YILMAZ 2014 年 10 月 23 日
編集済み: Geoff Hayes 2016 年 8 月 10 日
Hello,
I made a simple GUI . There is 2 text box in edit Style as Username and Password. But When I started GUI, I want to see cursor in Username Text box without any mouse click. regards,I couldn't success this for 2 days. Can you help me please.
  1 件のコメント
Adam
Adam 2014 年 10 月 23 日
You could try using java.robot. I used it in one our code tests for a line moving on an axis. It worked well, except for the fact that if the user happens to move the mouse it interfered with the test. But then if the user moves the mouse you wouldn't expect the cursor to still end up where you put it programmatically.

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 10 月 23 日
Try using uicontrol to set focus to the username text box.
If you are using GUIDE, then in the OpeningFcn just add the line
uicontrol(handles.edit1);
where edit1 is the handle to the edit text box for the username.
If not using guide, then you should be able to do the same call with the handle to the text box. Something like
figure;
hUsername = uicontrol('Style','edit','Position',[2 30 12 2],'Units','characters');
hPassword = uicontrol('Style','edit','Position',[2 26 12 2],'Units','characters');
% set focus
uicontrol(hUsername);
  1 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 10 月 27 日
Tevfik - I'm not too clear on what you mean by when new barcode entry came, How can delete old barcode from edit1 box and enter new barcode? What is the barcode - the username, or is this something different?

サインインしてコメントする。

その他の回答 (1 件)

Zoltán Csáti
Zoltán Csáti 2014 年 10 月 23 日
I think someone else also asked it. Here is the answer: http://www.mathworks.in/matlabcentral/newsreader/view_thread/80041

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by