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

gui text box cursor placement

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.

Best Answer

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);