diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index ebf4d7b83..220f45fcb 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ D04BA278D9EFA568C8D18A4C /* Windows.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BAD1BED44EAEB77FED8A4 /* Windows.swift */; }; D04BA2CBF0EFA04CC80EC1BC /* Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BAE80772D25834E440975 /* Window.swift */; }; D04BA308162F8043F8561D03 /* AXUIElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA40A4291E4F310527DBF /* AXUIElement.swift */; }; + D04BA30F92801F5960ACC844 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D04BA7A48641612933710091 /* MainMenu.xib */; }; D04BA3261C7DA5F48310E654 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA90C6C36DB1D65BC2B66 /* App.swift */; }; D04BA40A1C8B02448D720EA3 /* BaseLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA7ADB4B6C31B4887AEA3 /* BaseLabel.swift */; }; D04BA42AF817BCDF3F1F13F2 /* AppearanceTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BACD85D3966B4C9482E52 /* AppearanceTab.swift */; }; @@ -84,6 +85,7 @@ D04BA6F87B035BCBF2BEAEBC /* BoldLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoldLabel.swift; sourceTree = ""; }; D04BA6FA0F38687C3E420D77 /* TabViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = ""; }; D04BA78E3B4E73B40DB77174 /* CGWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGWindow.swift; sourceTree = ""; }; + D04BA7A48641612933710091 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; D04BA7ADB4B6C31B4887AEA3 /* BaseLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseLabel.swift; sourceTree = ""; }; D04BA7B6AAB0812631BBC7A2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.info; path = Info.plist; sourceTree = ""; }; D04BA7ECCE728582D9ECA613 /* determine_version.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = determine_version.sh; sourceTree = ""; }; @@ -238,6 +240,7 @@ isa = PBXGroup; children = ( D04BABC654F40BE74DA25BC7 /* SF-Pro-Text-Regular.otf */, + D04BA7A48641612933710091 /* MainMenu.xib */, ); path = resources; sourceTree = ""; @@ -431,6 +434,7 @@ buildActionMask = 2147483647; files = ( D04BA8373D4DE452C0C081ED /* SF-Pro-Text-Regular.otf in Resources */, + D04BA30F92801F5960ACC844 /* MainMenu.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/alt-tab-macos/resources/MainMenu.xib b/alt-tab-macos/resources/MainMenu.xib new file mode 100644 index 000000000..7138adbae --- /dev/null +++ b/alt-tab-macos/resources/MainMenu.xib @@ -0,0 +1,673 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/alt-tab-macos/ui/App.swift b/alt-tab-macos/ui/App.swift index 932f3d9ad..32c148738 100644 --- a/alt-tab-macos/ui/App.swift +++ b/alt-tab-macos/ui/App.swift @@ -29,12 +29,21 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate { SystemPermissions.ensureScreenRecordingCheckboxIsChecked() Preferences.loadFromDiskAndUpdateValues() statusItem = Menubar.make(self) + loadMainMenuXib() initPreferencesDependentComponents() Spaces.initialDiscovery() Applications.initialDiscovery() Keyboard.listenToGlobalEvents(self) } + // keyboard shortcuts are broken without a menu. We generated the default menu from XCode and load it + // see https://stackoverflow.com/a/3746058/2249756 + private func loadMainMenuXib() { + var menuObjects: NSArray? + Bundle.main.loadNibNamed("MainMenu", owner: self, topLevelObjects: &menuObjects) + menu = menuObjects?.first(where: {$0 is NSMenu }) as? NSMenu + } + // we put application code here which should be executed on init() and Preferences change func initPreferencesDependentComponents() { thumbnailsPanel = ThumbnailsPanel(self) diff --git a/alt-tab-macos/ui/generic-components/text/TextArea.swift b/alt-tab-macos/ui/generic-components/text/TextArea.swift index 413b0259c..30e30afef 100644 --- a/alt-tab-macos/ui/generic-components/text/TextArea.swift +++ b/alt-tab-macos/ui/generic-components/text/TextArea.swift @@ -7,13 +7,14 @@ class TextArea: NSTextView { convenience init(_ width: CGFloat, _ height: CGFloat, _ placeholder: String) { self.init(frame: .zero) + allowsUndo = true font = NSFont.systemFont(ofSize: NSFont.systemFontSize) textContainerInset = NSSize(width: TextArea.padding, height: TextArea.padding) textContainer!.lineFragmentPadding = 0 let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle paragraphStyle.maximumLineHeight = NSFont.systemFontSize + TextArea.magicOffset placeholderAttributedString = NSAttributedString(string: placeholder, attributes: [ - NSAttributedString.Key.font : NSFont.systemFont(ofSize: NSFont.systemFontSize), + NSAttributedString.Key.font: NSFont.systemFont(ofSize: NSFont.systemFontSize), NSAttributedString.Key.foregroundColor: NSColor.gray, NSAttributedString.Key.paragraphStyle: paragraphStyle, ])