Skip to content

Commit 40387a4

Browse files
committed
fix: enable Globe+F (fn+F) fullscreen shortcut for SwiftUI lifecycle app
SwiftUI lifecycle apps don't create a real NSMenuItem for "Enter Full Screen" — the shortcut shown in the View menu is a visual hint only, with no key equivalent binding. macOS maps Globe+F to ⌃⌘F, so install a local event monitor to bridge the gap.
1 parent b87317e commit 40387a4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

TablePro/AppDelegate.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,25 @@ class AppDelegate: NSObject, NSApplicationDelegate {
125125
self, selector: #selector(handleDatabaseDidConnect),
126126
name: .databaseDidConnect, object: nil
127127
)
128+
129+
installFullscreenKeyMonitor()
130+
}
131+
132+
// MARK: - Fullscreen Shortcut
133+
134+
/// macOS maps Globe+F (fn+F) to ⌃⌘F, but SwiftUI lifecycle apps don't
135+
/// create a real NSMenuItem for "Enter Full Screen" — the shortcut shown
136+
/// in the View menu is a visual hint only, with no key equivalent binding.
137+
private var fullscreenKeyMonitor: Any?
138+
139+
private func installFullscreenKeyMonitor() {
140+
fullscreenKeyMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { event in
141+
let mods = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
142+
guard mods == [.control, .command],
143+
event.keyCode == 3 else { return event }
144+
NSApp.keyWindow?.toggleFullScreen(nil)
145+
return nil
146+
}
128147
}
129148

130149
func applicationDidBecomeActive(_ notification: Notification) {

0 commit comments

Comments
 (0)