Set focus to objects. When starting a Matlab GUI it is normally not possible to activate the cursor in an edit object. Before you can type, you'll have to click with the mouse in the edit field. With setfocus it is possible to activate the cursor with program code by passing the object handle to setfocus. setfocus simply simulate a mouseclick in the area of the object.
The function doesnt work any more for 2014b! The mex file mouseclick cannot be executed.
Martin, I really like your solution to this problem. I was wondering if you have the source to mouseclick, to recompile it into a mex32 file since dll support is being phased out
Martin provides a very nice workaround. Exactly what I needed. Thanks man!
is this the same as uicontrol(handle)? I tried using this function before trying uicontrol which did what I wanted.
it took some time but actually i found
out that this only works with an small pause
mousePress(16) + mouseRelease(16)
at my system(linux);
but then its fine and
Thanks for the hint.
You can replace the MouseClick DLL with the following 2 lines in Matlab:
Input = java.awt.Robot;
The setfocus command does not handle all failure cases. There is no source code for the mouseclick command. It does not work on Unix. Ask me for an improved version solving all issues.
I have incorporated your mouseclick.dll file into my matlab program and find it extremely useful! thank you!
Very useful...thanks, Martin!
Great! Does the job, MATLAB should have a focus property settable in GUIDE!
Solved the problem. When will this be available in MATLAB itself?
Inserted a drawnow after deleting the callback to update the figure data
I noticed an error in my source file. (Typed a instead of h, line 29)