Application Keyboard Shortcut Problem

2 Ansichten (letzte 30 Tage)
Brian
Brian am 26 Aug. 2025
Bearbeitet: dpb am 28 Aug. 2025
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?

Antworten (1)

dpb
dpb am 28 Aug. 2025
Bearbeitet: dpb am 28 Aug. 2025
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.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by