WindowKeyPressFcn blocked when a uiprogressdlg is active - any workarounds?

7 vues (au cours des 30 derniers jours)
Will Grant
Will Grant le 9 Fév 2021
Réponse apportée : Abhas le 24 Fév 2025
I have a WindowKeyPressFcn on a uifigure and I would like it to continue to respond to key presses when a uiprogressdlg is active.
It appears that the uiprogressdlg blocks events going to the figure.
But uiprogressdlg does not appear to have any ability to add any key/button handlers directly to it. Only the ability to add the 'cancelable' button, which does not actually fire a callback when pressed.
I already tried inspecting the hidden properties of the uiprogressdlg object via struct(), and I can find handles back to the parent figure, but nothing that appears to be a control or object for the uiprogressdlg where I could add event handlers.
Are there any workarounds to this?

Réponses (1)

Abhas
Abhas le 24 Fév 2025
When a "uiprogressdlg" is active, it captures focus, preventing the "WindowKeyPressFcn" on the "uifigure" from receiving key press events. Since "uiprogressdlg" does not expose any direct event handlers for key presses, the figure’s "WindowKeyPressFcn" does not execute when the dialog is in focus.
To resolve this and have the key interaction linked to all subcomponents within the figure, the "WindowKeypressFcn" should be used by setting the focus back to the figure.
You may refer the below documentation and MATLAB Answers link to know more about the same:
  1. Figure Properties: https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-WindowKeyPressFcn
  2. https://www.mathworks.com/matlabcentral/answers/33224-gui-figure-focus
  3. https://www.mathworks.com/matlabcentral/answers/1907220-keypress-callback-not-working-for-a-second-called-uifigure
I hope this helps!

Catégories

En savoir plus sur Install Products dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by