From cb5245212a7e5b6141d6536171e57c0835b49811 Mon Sep 17 00:00:00 2001 From: vulgo <74738713+vulgo@users.noreply.github.com> Date: Thu, 9 Dec 2021 19:42:22 +0000 Subject: [PATCH] Add Edit menu --- usbtool.command | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/usbtool.command b/usbtool.command index db6bffd..eb395d9 100755 --- a/usbtool.command +++ b/usbtool.command @@ -123,7 +123,7 @@ extension DispatchQueue { extension FileHandle: TextOutputStream { public func write(_ string: String) { - self.write(string.data(using: .utf8)!) + write(string.data(using: .utf8)!) } } @@ -487,7 +487,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private lazy var mainMenu: NSMenu = { let processName = ProcessInfo.processInfo.processName let appMenu = NSMenuItem(title: processName) - appMenu.submenu = NSMenu(title: "Application Menu", items: [ + let editMenu = NSMenuItem(title: "Edit") + appMenu.submenu = NSMenu(title: processName, items: [ NSMenuItem(title: "About \(processName)", action: #selector(NSApplication.orderFrontStandardAboutPanel(_:))), NSMenuItem.separator(), @@ -495,7 +496,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate { action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q") ]) - return NSMenu(title: "Main Menu", items: [appMenu]) + editMenu.submenu = NSMenu(title: "Edit", items: [ + NSMenuItem(title: "Copy", + action: #selector(NSText.copy(_:)), + keyEquivalent: "c") + ]) + return NSMenu(title: "Main Menu", items: [appMenu, editMenu]) }() @objc func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {