mirror of https://github.com/mpv-player/mpv
mac/menu: add explicit menu type instead of an inferred type
with the use of an explicit type we can removed inferred type checks like separators/services menu by name or menus by sub configs.
This commit is contained in:
parent
16ea688115
commit
8a37f0f693
|
@ -20,44 +20,48 @@ extension MenuBar {
|
||||||
var config: Config?
|
var config: Config?
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MenuKey {
|
enum `Type`: Comparable {
|
||||||
case normalSize
|
case menu
|
||||||
case halfSize
|
case menuServices
|
||||||
case doubleSize
|
case separator
|
||||||
case minimize
|
case item
|
||||||
case zoom
|
case itemNormalSize
|
||||||
|
case itemHalfSize
|
||||||
|
case itemDoubleSize
|
||||||
|
case itemMinimize
|
||||||
|
case itemZoom
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
let name: String
|
let name: String
|
||||||
let key: String
|
let key: String
|
||||||
let modifiers: NSEvent.ModifierFlags
|
let modifiers: NSEvent.ModifierFlags
|
||||||
|
let type: Type
|
||||||
let action: Selector?
|
let action: Selector?
|
||||||
let target: AnyObject?
|
let target: AnyObject?
|
||||||
let command: String
|
let command: String
|
||||||
let url: String
|
let url: String
|
||||||
let commandSpecial: MenuKey?
|
var configs: [Config]
|
||||||
var configs: [Config]?
|
|
||||||
|
|
||||||
init(
|
init(
|
||||||
name: String = "",
|
name: String = "",
|
||||||
key: String = "",
|
key: String = "",
|
||||||
modifiers: NSEvent.ModifierFlags = .command,
|
modifiers: NSEvent.ModifierFlags = .command,
|
||||||
|
type: Type = .item,
|
||||||
action: Selector? = nil,
|
action: Selector? = nil,
|
||||||
target: AnyObject? = nil,
|
target: AnyObject? = nil,
|
||||||
command: String = "",
|
command: String = "",
|
||||||
url: String = "",
|
url: String = "",
|
||||||
commandSpecial: MenuKey? = nil,
|
configs: [Config] = []
|
||||||
configs: [Config]? = nil
|
|
||||||
) {
|
) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.key = key
|
self.key = key
|
||||||
self.modifiers = modifiers
|
self.modifiers = modifiers
|
||||||
|
self.type = configs.isEmpty ? type : .menu
|
||||||
self.action = action
|
self.action = action
|
||||||
self.target = target
|
self.target = target
|
||||||
self.command = command
|
self.command = command
|
||||||
self.url = url
|
self.url = url
|
||||||
self.commandSpecial = commandSpecial
|
|
||||||
self.configs = configs
|
self.configs = configs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +71,7 @@ class MenuBar: NSObject {
|
||||||
let mainMenu = NSMenu(title: "Main")
|
let mainMenu = NSMenu(title: "Main")
|
||||||
let servicesMenu = NSMenu(title: "Services")
|
let servicesMenu = NSMenu(title: "Services")
|
||||||
var menuConfigs: [Config] = []
|
var menuConfigs: [Config] = []
|
||||||
var dynamicMenuItems: [MenuKey:[MenuItem]] = [:]
|
var dynamicMenuItems: [Type:[MenuItem]] = [:]
|
||||||
let appIcon: NSImage
|
let appIcon: NSImage
|
||||||
|
|
||||||
@objc override init() {
|
@objc override init() {
|
||||||
|
@ -81,7 +85,7 @@ class MenuBar: NSObject {
|
||||||
|
|
||||||
let appMenuConfigs = [
|
let appMenuConfigs = [
|
||||||
Config(name: "About mpv", action: #selector(about), target: self),
|
Config(name: "About mpv", action: #selector(about), target: self),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(
|
Config(
|
||||||
name: "Settings…",
|
name: "Settings…",
|
||||||
key: ",",
|
key: ",",
|
||||||
|
@ -95,13 +99,13 @@ class MenuBar: NSObject {
|
||||||
target: self,
|
target: self,
|
||||||
url: "input.conf"
|
url: "input.conf"
|
||||||
),
|
),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Services", configs: []),
|
Config(name: "Services", type: .menuServices),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Hide mpv", key: "h", action: #selector(NSApp.hide(_:))),
|
Config(name: "Hide mpv", key: "h", action: #selector(NSApp.hide(_:))),
|
||||||
Config(name: "Hide Others", key: "h", modifiers: [.command, .option], action: #selector(NSApp.hideOtherApplications(_:))),
|
Config(name: "Hide Others", key: "h", modifiers: [.command, .option], action: #selector(NSApp.hideOtherApplications(_:))),
|
||||||
Config(name: "Show All", action: #selector(NSApp.unhideAllApplications(_:))),
|
Config(name: "Show All", action: #selector(NSApp.unhideAllApplications(_:))),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Quit and Remember Position", action: #selector(quit(_:)), target: self, command: "quit-watch-later"),
|
Config(name: "Quit and Remember Position", action: #selector(quit(_:)), target: self, command: "quit-watch-later"),
|
||||||
Config(name: "Quit mpv", key: "q", action: #selector(quit(_:)), target: self, command: "quit"),
|
Config(name: "Quit mpv", key: "q", action: #selector(quit(_:)), target: self, command: "quit"),
|
||||||
]
|
]
|
||||||
|
@ -110,7 +114,7 @@ class MenuBar: NSObject {
|
||||||
Config(name: "Open File…", key: "o", action: #selector(openFiles), target: self),
|
Config(name: "Open File…", key: "o", action: #selector(openFiles), target: self),
|
||||||
Config(name: "Open URL…", key: "O", action: #selector(openUrl), target: self),
|
Config(name: "Open URL…", key: "O", action: #selector(openUrl), target: self),
|
||||||
Config(name: "Open Playlist…", action: #selector(openPlaylist), target: self),
|
Config(name: "Open Playlist…", action: #selector(openPlaylist), target: self),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Close", key: "w", action: #selector(NSWindow.performClose(_:))),
|
Config(name: "Close", key: "w", action: #selector(NSWindow.performClose(_:))),
|
||||||
Config(name: "Save Screenshot", action: #selector(command(_:)), target: self, command: "async screenshot"),
|
Config(name: "Save Screenshot", action: #selector(command(_:)), target: self, command: "async screenshot"),
|
||||||
]
|
]
|
||||||
|
@ -118,7 +122,7 @@ class MenuBar: NSObject {
|
||||||
let editMenuConfigs = [
|
let editMenuConfigs = [
|
||||||
Config(name: "Undo", key: "z", action: Selector(("undo:"))),
|
Config(name: "Undo", key: "z", action: Selector(("undo:"))),
|
||||||
Config(name: "Redo", key: "Z", action: Selector(("redo:"))),
|
Config(name: "Redo", key: "Z", action: Selector(("redo:"))),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Cut", key: "x", action: #selector(NSText.cut(_:))),
|
Config(name: "Cut", key: "x", action: #selector(NSText.cut(_:))),
|
||||||
Config(name: "Copy", key: "c", action: #selector(NSText.copy(_:))),
|
Config(name: "Copy", key: "c", action: #selector(NSText.copy(_:))),
|
||||||
Config(name: "Paste", key: "v", action: #selector(NSText.paste(_:))),
|
Config(name: "Paste", key: "v", action: #selector(NSText.paste(_:))),
|
||||||
|
@ -137,7 +141,7 @@ class MenuBar: NSObject {
|
||||||
]
|
]
|
||||||
#if HAVE_MACOS_TOUCHBAR
|
#if HAVE_MACOS_TOUCHBAR
|
||||||
viewMenuConfigs += [
|
viewMenuConfigs += [
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Customize Touch Bar…", action: #selector(NSApp.toggleTouchBarCustomizationPalette(_:))),
|
Config(name: "Customize Touch Bar…", action: #selector(NSApp.toggleTouchBarCustomizationPalette(_:))),
|
||||||
]
|
]
|
||||||
#endif
|
#endif
|
||||||
|
@ -146,28 +150,28 @@ class MenuBar: NSObject {
|
||||||
Config(name: "Zoom Out", action: #selector(command(_:)), target: self, command: "add panscan -0.1"),
|
Config(name: "Zoom Out", action: #selector(command(_:)), target: self, command: "add panscan -0.1"),
|
||||||
Config(name: "Zoom In", action: #selector(command(_:)), target: self, command: "add panscan 0.1"),
|
Config(name: "Zoom In", action: #selector(command(_:)), target: self, command: "add panscan 0.1"),
|
||||||
Config(name: "Reset Zoom", action: #selector(command(_:)), target: self, command: "set panscan 0"),
|
Config(name: "Reset Zoom", action: #selector(command(_:)), target: self, command: "set panscan 0"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Aspect Ratio 4:3", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"4:3\""),
|
Config(name: "Aspect Ratio 4:3", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"4:3\""),
|
||||||
Config(name: "Aspect Ratio 16:9", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"16:9\""),
|
Config(name: "Aspect Ratio 16:9", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"16:9\""),
|
||||||
Config(name: "Aspect Ratio 1.85:1", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"1.85:1\""),
|
Config(name: "Aspect Ratio 1.85:1", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"1.85:1\""),
|
||||||
Config(name: "Aspect Ratio 2.35:1", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"2.35:1\""),
|
Config(name: "Aspect Ratio 2.35:1", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"2.35:1\""),
|
||||||
Config(name: "Reset Aspect Ratio", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"-1\""),
|
Config(name: "Reset Aspect Ratio", action: #selector(command(_:)), target: self, command: "set video-aspect-override \"-1\""),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Rotate Left", action: #selector(command(_:)), target: self, command: "cycle-values video-rotate 0 270 180 90"),
|
Config(name: "Rotate Left", action: #selector(command(_:)), target: self, command: "cycle-values video-rotate 0 270 180 90"),
|
||||||
Config(name: "Rotate Right", action: #selector(command(_:)), target: self, command: "cycle-values video-rotate 90 180 270 0"),
|
Config(name: "Rotate Right", action: #selector(command(_:)), target: self, command: "cycle-values video-rotate 90 180 270 0"),
|
||||||
Config(name: "Reset Rotation", action: #selector(command(_:)), target: self, command: "set video-rotate 0"),
|
Config(name: "Reset Rotation", action: #selector(command(_:)), target: self, command: "set video-rotate 0"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Half Size", key: "0", commandSpecial: .halfSize),
|
Config(name: "Half Size", key: "0", type: .itemHalfSize),
|
||||||
Config(name: "Normal Size", key: "1", commandSpecial: .normalSize),
|
Config(name: "Normal Size", key: "1", type: .itemNormalSize),
|
||||||
Config(name: "Double Size", key: "2", commandSpecial: .doubleSize),
|
Config(name: "Double Size", key: "2", type: .itemDoubleSize),
|
||||||
]
|
]
|
||||||
|
|
||||||
let audioMenuConfigs = [
|
let audioMenuConfigs = [
|
||||||
Config(name: "Next Audio Track", action: #selector(command(_:)), target: self, command: "cycle audio"),
|
Config(name: "Next Audio Track", action: #selector(command(_:)), target: self, command: "cycle audio"),
|
||||||
Config(name: "Previous Audio Track", action: #selector(command(_:)), target: self, command: "cycle audio down"),
|
Config(name: "Previous Audio Track", action: #selector(command(_:)), target: self, command: "cycle audio down"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Toggle Mute", action: #selector(command(_:)), target: self, command: "cycle mute"),
|
Config(name: "Toggle Mute", action: #selector(command(_:)), target: self, command: "cycle mute"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Play Audio Later", action: #selector(command(_:)), target: self, command: "add audio-delay 0.1"),
|
Config(name: "Play Audio Later", action: #selector(command(_:)), target: self, command: "add audio-delay 0.1"),
|
||||||
Config(name: "Play Audio Earlier", action: #selector(command(_:)), target: self, command: "add audio-delay -0.1"),
|
Config(name: "Play Audio Earlier", action: #selector(command(_:)), target: self, command: "add audio-delay -0.1"),
|
||||||
Config(name: "Reset Audio Delay", action: #selector(command(_:)), target: self, command: "set audio-delay 0.0"),
|
Config(name: "Reset Audio Delay", action: #selector(command(_:)), target: self, command: "set audio-delay 0.0"),
|
||||||
|
@ -176,9 +180,9 @@ class MenuBar: NSObject {
|
||||||
let subtitleMenuConfigs = [
|
let subtitleMenuConfigs = [
|
||||||
Config(name: "Next Subtitle Track", action: #selector(command(_:)), target: self, command: "cycle sub"),
|
Config(name: "Next Subtitle Track", action: #selector(command(_:)), target: self, command: "cycle sub"),
|
||||||
Config(name: "Previous Subtitle Track", action: #selector(command(_:)), target: self, command: "cycle sub down"),
|
Config(name: "Previous Subtitle Track", action: #selector(command(_:)), target: self, command: "cycle sub down"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Toggle Force Style", action: #selector(command(_:)), target: self, command: "cycle-values sub-ass-override \"force\" \"no\""),
|
Config(name: "Toggle Force Style", action: #selector(command(_:)), target: self, command: "cycle-values sub-ass-override \"force\" \"no\""),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Display Subtitles Later", action: #selector(command(_:)), target: self, command: "add sub-delay 0.1"),
|
Config(name: "Display Subtitles Later", action: #selector(command(_:)), target: self, command: "add sub-delay 0.1"),
|
||||||
Config(name: "Display Subtitles Earlier", action: #selector(command(_:)), target: self, command: "add sub-delay -0.1"),
|
Config(name: "Display Subtitles Earlier", action: #selector(command(_:)), target: self, command: "add sub-delay -0.1"),
|
||||||
Config(name: "Reset Subtitle Delay", action: #selector(command(_:)), target: self, command: "set sub-delay 0.0"),
|
Config(name: "Reset Subtitle Delay", action: #selector(command(_:)), target: self, command: "set sub-delay 0.0"),
|
||||||
|
@ -189,38 +193,38 @@ class MenuBar: NSObject {
|
||||||
Config(name: "Increase Speed", action: #selector(command(_:)), target: self, command: "add speed 0.1"),
|
Config(name: "Increase Speed", action: #selector(command(_:)), target: self, command: "add speed 0.1"),
|
||||||
Config(name: "Decrease Speed", action: #selector(command(_:)), target: self, command: "add speed -0.1"),
|
Config(name: "Decrease Speed", action: #selector(command(_:)), target: self, command: "add speed -0.1"),
|
||||||
Config(name: "Reset Speed", action: #selector(command(_:)), target: self, command: "set speed 1.0"),
|
Config(name: "Reset Speed", action: #selector(command(_:)), target: self, command: "set speed 1.0"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Show Playlist", action: #selector(command(_:)), target: self, command: "script-message osc-playlist"),
|
Config(name: "Show Playlist", action: #selector(command(_:)), target: self, command: "script-message osc-playlist"),
|
||||||
Config(name: "Show Chapters", action: #selector(command(_:)), target: self, command: "script-message osc-chapterlist"),
|
Config(name: "Show Chapters", action: #selector(command(_:)), target: self, command: "script-message osc-chapterlist"),
|
||||||
Config(name: "Show Tracks", action: #selector(command(_:)), target: self, command: "script-message osc-tracklist"),
|
Config(name: "Show Tracks", action: #selector(command(_:)), target: self, command: "script-message osc-tracklist"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Next File", action: #selector(command(_:)), target: self, command: "playlist-next"),
|
Config(name: "Next File", action: #selector(command(_:)), target: self, command: "playlist-next"),
|
||||||
Config(name: "Previous File", action: #selector(command(_:)), target: self, command: "playlist-prev"),
|
Config(name: "Previous File", action: #selector(command(_:)), target: self, command: "playlist-prev"),
|
||||||
Config(name: "Toggle Loop File", action: #selector(command(_:)), target: self, command: "cycle-values loop-file \"inf\" \"no\""),
|
Config(name: "Toggle Loop File", action: #selector(command(_:)), target: self, command: "cycle-values loop-file \"inf\" \"no\""),
|
||||||
Config(name: "Toggle Loop Playlist", action: #selector(command(_:)), target: self, command: "cycle-values loop-playlist \"inf\" \"no\""),
|
Config(name: "Toggle Loop Playlist", action: #selector(command(_:)), target: self, command: "cycle-values loop-playlist \"inf\" \"no\""),
|
||||||
Config(name: "Shuffle", action: #selector(command(_:)), target: self, command: "playlist-shuffle"),
|
Config(name: "Shuffle", action: #selector(command(_:)), target: self, command: "playlist-shuffle"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Next Chapter", action: #selector(command(_:)), target: self, command: "add chapter 1"),
|
Config(name: "Next Chapter", action: #selector(command(_:)), target: self, command: "add chapter 1"),
|
||||||
Config(name: "Previous Chapter", action: #selector(command(_:)), target: self, command: "add chapter -1"),
|
Config(name: "Previous Chapter", action: #selector(command(_:)), target: self, command: "add chapter -1"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Step Forward", action: #selector(command(_:)), target: self, command: "frame-step"),
|
Config(name: "Step Forward", action: #selector(command(_:)), target: self, command: "frame-step"),
|
||||||
Config(name: "Step Backward", action: #selector(command(_:)), target: self, command: "frame-back-step"),
|
Config(name: "Step Backward", action: #selector(command(_:)), target: self, command: "frame-back-step"),
|
||||||
]
|
]
|
||||||
|
|
||||||
let windowMenuConfigs = [
|
let windowMenuConfigs = [
|
||||||
Config(name: "Minimize", key: "m", commandSpecial: .minimize),
|
Config(name: "Minimize", key: "m", type: .itemMinimize),
|
||||||
Config(name: "Zoom", commandSpecial: .zoom),
|
Config(name: "Zoom", type: .itemZoom),
|
||||||
]
|
]
|
||||||
|
|
||||||
var helpMenuConfigs = [
|
var helpMenuConfigs = [
|
||||||
Config(name: "mpv Website…", action: #selector(url(_:)), target: self, url: "https://mpv.io"),
|
Config(name: "mpv Website…", action: #selector(url(_:)), target: self, url: "https://mpv.io"),
|
||||||
Config(name: "mpv on GitHub…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv"),
|
Config(name: "mpv on GitHub…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Online Manual…", action: #selector(url(_:)), target: self, url: "https://mpv.io/manual/master/"),
|
Config(name: "Online Manual…", action: #selector(url(_:)), target: self, url: "https://mpv.io/manual/master/"),
|
||||||
Config(name: "Online Wiki…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/wiki"),
|
Config(name: "Online Wiki…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/wiki"),
|
||||||
Config(name: "Release Notes…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/blob/master/RELEASE_NOTES"),
|
Config(name: "Release Notes…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/blob/master/RELEASE_NOTES"),
|
||||||
Config(name: "Keyboard Shortcuts…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/blob/master/etc/input.conf"),
|
Config(name: "Keyboard Shortcuts…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/blob/master/etc/input.conf"),
|
||||||
Config(name: "separator"),
|
Config(type: .separator),
|
||||||
Config(name: "Report Issue…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/issues/new/choose"),
|
Config(name: "Report Issue…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/issues/new/choose"),
|
||||||
]
|
]
|
||||||
if ProcessInfo.processInfo.environment["MPVBUNDLE"] == "true" {
|
if ProcessInfo.processInfo.environment["MPVBUNDLE"] == "true" {
|
||||||
|
@ -251,14 +255,14 @@ class MenuBar: NSObject {
|
||||||
for config in configs {
|
for config in configs {
|
||||||
let item = createMenuItem(parentMenu: parentMenu, config: config)
|
let item = createMenuItem(parentMenu: parentMenu, config: config)
|
||||||
|
|
||||||
if config.configs != nil {
|
if config.type <= .menuServices {
|
||||||
let menu = config.name == "Services" ? servicesMenu : NSMenu(title: config.name)
|
let menu = config.type == .menuServices ? servicesMenu : NSMenu(title: config.name)
|
||||||
item.submenu = menu
|
item.submenu = menu
|
||||||
createMenu(parentMenu: menu, configs: config.configs ?? [])
|
createMenu(parentMenu: menu, configs: config.configs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let cmd = config.commandSpecial {
|
if config.type > Type.item {
|
||||||
dynamicMenuItems[cmd] = (dynamicMenuItems[cmd] ?? []) + [item]
|
dynamicMenuItems[config.type] = (dynamicMenuItems[config.type] ?? []) + [item]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +273,7 @@ class MenuBar: NSObject {
|
||||||
item.target = config.target
|
item.target = config.target
|
||||||
item.keyEquivalentModifierMask = config.modifiers
|
item.keyEquivalentModifierMask = config.modifiers
|
||||||
|
|
||||||
if config.name == "separator" {
|
if config.type == .separator {
|
||||||
item = MenuItem.separator() as? MenuItem ?? item
|
item = MenuItem.separator() as? MenuItem ?? item
|
||||||
}
|
}
|
||||||
parentMenu.addItem(item)
|
parentMenu.addItem(item)
|
||||||
|
@ -392,7 +396,7 @@ class MenuBar: NSObject {
|
||||||
alert.runModal()
|
alert.runModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
func register(_ selector: Selector, key: MenuKey) {
|
func register(_ selector: Selector, key: Type) {
|
||||||
for menuItem in dynamicMenuItems[key] ?? [] {
|
for menuItem in dynamicMenuItems[key] ?? [] {
|
||||||
menuItem.action = selector
|
menuItem.action = selector
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,11 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
unfScreen = screen
|
unfScreen = screen
|
||||||
|
|
||||||
if let app = NSApp as? Application {
|
if let app = NSApp as? Application {
|
||||||
app.menuBar.register(#selector(setHalfWindowSize), key: .halfSize)
|
app.menuBar.register(#selector(setHalfWindowSize), key: .itemHalfSize)
|
||||||
app.menuBar.register(#selector(setNormalWindowSize), key: .normalSize)
|
app.menuBar.register(#selector(setNormalWindowSize), key: .itemNormalSize)
|
||||||
app.menuBar.register(#selector(setDoubleWindowSize), key: .doubleSize)
|
app.menuBar.register(#selector(setDoubleWindowSize), key: .itemDoubleSize)
|
||||||
app.menuBar.register(#selector(performMiniaturize(_:)), key: .minimize)
|
app.menuBar.register(#selector(performMiniaturize(_:)), key: .itemMinimize)
|
||||||
app.menuBar.register(#selector(performZoom(_:)), key: .zoom)
|
app.menuBar.register(#selector(performZoom(_:)), key: .itemZoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue