Posts in "code"

DFU Blaster UI and Keyboard Shortcuts

I am working on an update to DFU Blaster to reorganize the UI a bit to make it a bit more compact (DFU Blaster Pro is an app from Twocanoes Software to easily put a Mac into restore mode and automate the restore process). SwiftUI makes putting keyboard shortcuts in the menus difficult so I added in the keyboard shortcuts but didn’t have a good way to add them to associated menu item. SwiftUI seems to lean towards menu-less apps (iOS influenced?) and it wasn’t worth it to me force a mac specific feature.

I took a look with fresh eyes and using SwiftUI @State, I can detect when the command key is down, set a state, and then show the keyboard shortcuts in next to the UI element it triggers. I neat side effect is that all the keyboard shortcuts require the command key, so you are about 1/2 way to typing the shortcut when hitting command.

As always, the current beta is here