Application Keyboard Shortcut Problem
20 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
dpb
on 28 Aug 2025 at 15:35
Edited: dpb
on 28 Aug 2025 at 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.
0 Comments
See Also
Categories
Find more on Startup and Shutdown 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!