prevent figure window to be hidden after keypress

3 views (last 30 days)
Hi,
I have a script in which a figure window pops up and an inputdlg, whereas the inputdlg will close after 10 seconds. The user has to submit an answer within these 10 seconds and submit this by pressing 'enter'. However, if the user presses 'enter' too late (after the inputdlg has closed so only the figure window is left) the figure window will hide behind another window
How do I prevent this? How do I make sure the figure window won't be hiddenafter pressing any key.
Thank you!
  6 Comments
DGM
DGM on 9 Dec 2021
Edited: DGM on 9 Dec 2021
The figure gets hidden due to the window manager-specific behavior regarding window stacking and focus. There's probably a workaround, unless it involves adding something to the figure that allows it to accept keyboard events, which seems terribly ineffective.
There's always the option to force the window to always stay on top by setting the WindowStyle property to "modal" (probably not desired) or setting the WindowStyle property to "alwaysontop" (works for uifigures but not figures; requires R2021a or newer)
This might also work, though I haven't tried it and don't know the exact behavior.
Using 'modal' style would definitely force the figure to stay on top, but it would prevent anything else from receiving keyboard or mouse events until the figure is closed. Using 'alwaysontop' simply keeps the window on top but lets underlying windows receive events.
There are obviously ways to do it by using system() calls to change window-manager-specific settings for the window, but that's environment-specific.

Sign in to comment.

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!