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!
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!