Setting focus to background figure or invisible figure

11 views (last 30 days)
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!

Answers (1)

Image Analyst
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
Jurgens Wolfaardt
Jurgens Wolfaardt on 16 Aug 2017
Edited: Jurgens Wolfaardt on 16 Aug 2017
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.

Sign in to comment.

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!