Setting focus to background figure or invisible figure
11 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 16 Aug 2017
Edited: Image Analyst
on 16 Aug 2017
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 Comment
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!