GUI Keyboard Commands HELP

Hi,
I have a complex GUI, but I have what I think is a fairly simple problem.
I have keyboard commands set to various commands including button presses (This is because eventually the GUI needs to operate as keyboard only). The problem I have is that I have to manually click the figure window before it allows the GUI to recognise that I'm pressing keyboard buttons.
Is there a way to set the current figure to be the focus so that I don't need to use the mouse?
Thanks in advance!
JD

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 12월 11일

0 개 추천

Yes!
You need to steal focu back to the figure from whatever uicontrol/uipanel/axes/etc. has stolen it.
To do this, at the end of a callback function for one of these widgets:
set(H, 'Enable', 'off');
drawnow;
set(H, 'Enable', 'on');
Where H is the handle to that widget.

댓글 수: 4

John
John 2012년 12월 11일
Humm... doesn't seem to like that.
Error using hg.figure/set
The name 'Enable' is not an accessible property for an instance of class 'figure'.
Error in ROTv14>Begin_Trial_Callback (line 168)
set(H, 'Enable', 'off');
Sean de Wolski
Sean de Wolski 2012년 12월 11일
You don't want to disable the figure; You want to disable the widget that stole focus from the figure!
You can use this file as a reference:
I had to take the above steps any time one of the widgets stole focus from the figure.
Jan
Jan 2012년 12월 12일
@John: In Sean's example, H is the handle of the uicontrol or axes object, not the handle of the figure.
John
John 2013년 2월 19일
Thanks Saun and Jan. Much appreciated. I've been working on other stuff until now so sorry for the delay in my thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2012년 12월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by