Application Keyboard Shortcut Problem

20 visualizaciones (últimos 30 días)
Brian
Brian el 26 de Ag. de 2025 a las 22:01
Editada: dpb el 28 de Ag. de 2025 a las 19:09
I am trying to add keyboard shortcuts to my applications. I'm using the WindowKeyPress callback with a series of if/elseif statements with event.Modifier and event.Key comparisons to trigger other button press functions (for example, Ctrl+L will lock/unlock the admin rights, Ctrl+I will initialize the system, Ctrl+S will start testing). Unfortunately, a bunch of those functions end with a uialert (or uiconfirm) letting the user know that the process has ended, and this seems to draw focus away from the figure window, preventing another shortcut without clicking somewhere in the window.
I've tried adding "figure(app.UIFigure)" and "axes(app.UIAxes)" to return focus to either of those elements so that the next shortcut would run, but that didn't work. Is there something here that I'm missing?

Respuestas (1)

dpb
dpb el 28 de Ag. de 2025 a las 15:35
Editada: dpb el 28 de Ag. de 2025 a las 19:09
It's a known issue that focus doesn't automagically revert back to figure after modal window...you can try using <focus> in your callbacks to set focus to one of the interactive components and see if that helps...it has the side effect of highlighting the selected control that may or may not be desirable, or it may not be suitable for you particular app at all. AFAIK, that's the only other hammer in the tool bag.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by