Path: news.mathworks.com!not-for-mail
From: "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How do I give focus to a figure?
Date: Tue, 1 Sep 2009 19:25:20 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 18
Message-ID: <h7jsf0$k7p$1@fred.mathworks.com>
References: <fg3s2p$jgd$1@fred.mathworks.com>
Reply-To: "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251833120 20729 172.30.248.38 (1 Sep 2009 19:25:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 1 Sep 2009 19:25:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: news.mathworks.com comp.soft-sys.matlab:567672

Dear Jochen Smolka!

> in my application I have a large number of buttons and an
> axis object in a figure. After each button press I would
> like to return focus to the figure, so that key presses are
> evaluated by the figure's KeyPressFcn. Is there a way to do
> this programmatically?

See thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/235825

There I explained, that the following piece of code can be inserted in the callbacks of the buttons:
  set(hObject, 'Enable', 'off');
  drawnow;
  set(hObject, 'Enable', 'on');
[hObject] is the handle of the current button. Then the focus has moved to the figure again. Actually this should be performed by "figure(FigureHandle)" also, but this does not work for unknown reasons.
Unfortunately the above trick does not work for Matlab 2008a.

Good luck, Jan