Setting focus to background figure or invisible figure

10 次查看(过去 30 天)
Hi All
I have a guide-GUI that generates figures (of the same size and screen position) that need to be compared sometimes, for which the user can use alt-esc and alt-shift-esc to flick to-and-fro. To avoid the finger judo I have a WindowKeyPressFcn acting on leftarrow and rightarrow for this purpose.
It is hard enough keeping the focus on the GUI window after you start pushing arrows keys; the figure easily loses focus (without the mouse clicking elsewhere at all) and the keypress starts acting in the command window. To solve this I do an emulated mouseclick in the GUI figure at the end of the callback.
The real problem comes in when the user has one monitor, because the figures are big and therefore obscure the GUI so my emulated mouse click doesn't work. Is there a way to set focus on a figure in the background, or better yet an invisible figure? If the callback can work from an invisible figure I can simply use a third key (like escape) to make it visible again.
Appreciating any advice!

回答(1 个)

Image Analyst
Image Analyst 2017-8-16
编辑:Image Analyst 2017-8-16
If you have the variable handle to the figure, you can bring it to the front with the figure command.
hFig = figure(); % Create new figure and save its handle.
% Now do something to bring other figures in front.
% Now bring hFig to the foreground:
figure(hFig);
You could put all the figure names in a popup control on your main GUI so the user can select which figure to bring to the foreground.
  1 个评论
Jurgens Wolfaardt
Jurgens Wolfaardt 2017-8-16
编辑:Jurgens Wolfaardt 2017-8-16
HI! That is how I reveal the obscured graph (figure), but I can't do that to keep focus on the gui (to have it ready to trigger a callback) because: 1) Somehow figure() does not keep focus fixed on the object very well, don't know why 2) figure() brings the object to the foreground and obscures my pretty pictures. I want to dictate when the GUI comes to the front again with a keypress. 3) A popup also needs the GUI to be front so you have to switch to the gui, obscuring the figure again...
I'll just have to make space for those figures on the GUI figure itself.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by