Skip to content

Commit 435751e

Browse files
committed
fix: replace full-screen event monitor with proper CommandGroup
1 parent 4acbfb9 commit 435751e

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

TablePro/AppDelegate.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
136136
name: .databaseDidConnect, object: nil
137137
)
138138

139-
installFullscreenKeyMonitor()
140-
}
141-
142-
// MARK: - Fullscreen Shortcut
143-
144-
/// macOS maps Globe+F (fn+F) to ⌃⌘F, but SwiftUI lifecycle apps don't
145-
/// create a real NSMenuItem for "Enter Full Screen" — the shortcut shown
146-
/// in the View menu is a visual hint only, with no key equivalent binding.
147-
private var fullscreenKeyMonitor: Any?
148-
149-
private func installFullscreenKeyMonitor() {
150-
fullscreenKeyMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { event in
151-
let mods = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
152-
guard mods == [.control, .command],
153-
event.keyCode == KeyCode.f.rawValue else { return event }
154-
NSApp.keyWindow?.toggleFullScreen(nil)
155-
return nil
156-
}
157139
}
158140

159141
func applicationDidBecomeActive(_ notification: Notification) {

TablePro/TableProApp.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ struct AppMenuCommands: Commands {
407407
.keyboardShortcut("-", modifiers: .command)
408408
}
409409

410+
CommandGroup(after: .toolbar) {
411+
Button {
412+
NSApp.keyWindow?.toggleFullScreen(nil)
413+
} label: {
414+
Text("Enter Full Screen")
415+
}
416+
.keyboardShortcut("f", modifiers: [.control, .command])
417+
}
418+
410419
// Tab navigation shortcuts — native macOS window tabs
411420
CommandGroup(after: .windowArrangement) {
412421
// Tab switching by number (Cmd+1 through Cmd+9)

0 commit comments

Comments
 (0)