No BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.2 | 11 ratings Rate this file 15 Downloads (last 30 days) File Size: 1.97 KB File ID: #1898 Version: 1.0



Martin Weber (view profile)


27 Jun 2002 (Updated )

Program to set focus to objects (edit etc) without clicking with the mouse on them.

| Watch this File

File Information

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.


This file inspired Clickfocus and J Mouse Emu: Mouse Emulator (V2.3).

MATLAB release MATLAB 6.1 (R12.1)
Other requirements Windows
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
13 Apr 2016 Andrea Libri  
20 Nov 2014 Song

Song (view profile)

The function doesnt work any more for 2014b! The mex file mouseclick cannot be executed.

Comment only
11 Jul 2010 James Rao

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

Comment only
10 Jul 2008 Tom N

Martin provides a very nice workaround. Exactly what I needed. Thanks man!

04 Oct 2007 Marc O Donnagain

is this the same as uicontrol(handle)? I tried using this function before trying uicontrol which did what I wanted.

23 Feb 2007 Jo Bergs

@ Anthony:
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
platform-independant(i guess).
Thanks for the hint.

21 Apr 2006 Anthony Beaucamp

You can replace the MouseClick DLL with the following 2 lines in Matlab:
Input = java.awt.Robot;

05 Sep 2005 Ralph Schleicher

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.

29 Mar 2005 JTB .

I have incorporated your mouseclick.dll file into my matlab program and find it extremely useful! thank you!

19 May 2004 Stefan Bleeck

works :-)

24 Mar 2004 Brett Shoelson

Very useful...thanks, Martin!

01 Aug 2003 David Abraham

Great! Does the job, MATLAB should have a focus property settable in GUIDE!

24 Dec 2002 Yaron Keren

Solved the problem. When will this be available in MATLAB itself?

06 Aug 2002

I noticed an error in my source file. (Typed a instead of h, line 29)

23 Aug 2002

Inserted a drawnow after deleting the callback to update the figure data

Contact us