Fix windows and help menus
This commit is contained in:
parent
6e266574b0
commit
51d1a9137f
@ -50,7 +50,6 @@ public class MacApp: AppStorage {
|
|||||||
/// The windows menu.
|
/// The windows menu.
|
||||||
func windowsMenu() {
|
func windowsMenu() {
|
||||||
let windowsMenu = NSMenu()
|
let windowsMenu = NSMenu()
|
||||||
mainMenu.addItem(windowsItem)
|
|
||||||
windowsItem.submenu = windowsMenu
|
windowsItem.submenu = windowsMenu
|
||||||
app.windowsMenu = windowsMenu
|
app.windowsMenu = windowsMenu
|
||||||
}
|
}
|
||||||
@ -58,18 +57,24 @@ public class MacApp: AppStorage {
|
|||||||
/// The help menu.
|
/// The help menu.
|
||||||
func helpMenu() {
|
func helpMenu() {
|
||||||
let helpMenu = NSMenu()
|
let helpMenu = NSMenu()
|
||||||
mainMenu.addItem(helpItem)
|
|
||||||
helpItem.submenu = helpMenu
|
helpItem.submenu = helpMenu
|
||||||
app.helpMenu = helpMenu
|
app.helpMenu = helpMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add the windows and help menus.
|
||||||
|
func addMenus() {
|
||||||
|
mainMenu.addItem(windowsItem)
|
||||||
|
mainMenu.addItem(helpItem)
|
||||||
|
}
|
||||||
|
|
||||||
/// Execute the app.
|
/// Execute the app.
|
||||||
/// - Parameter setup: Set the scene elements up.
|
/// - Parameter setup: Set the scene elements up.
|
||||||
public func run(setup: @escaping () -> Void) {
|
public func run(setup: @escaping () -> Void) {
|
||||||
appMenu()
|
appMenu()
|
||||||
setup()
|
|
||||||
windowsMenu()
|
windowsMenu()
|
||||||
helpMenu()
|
helpMenu()
|
||||||
|
setup()
|
||||||
|
addMenus()
|
||||||
app.run()
|
app.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,9 +59,14 @@ public struct MenuBar: MacSceneElement {
|
|||||||
let scene = SceneStorage(id: id, pointer: app.mainMenu) { }
|
let scene = SceneStorage(id: id, pointer: app.mainMenu) { }
|
||||||
let data = WidgetData(sceneStorage: scene, appStorage: app)
|
let data = WidgetData(sceneStorage: scene, appStorage: app)
|
||||||
let storage = MenuCollection { self.content }.getMenu(data: data, menu: app.mainMenu)
|
let storage = MenuCollection { self.content }.getMenu(data: data, menu: app.mainMenu)
|
||||||
|
print(app.helpItem.submenu)
|
||||||
let appStorage = MenuCollection { self.app }.getMenu(data: data, menu: app.appItem.submenu)
|
let appStorage = MenuCollection { self.app }.getMenu(data: data, menu: app.appItem.submenu)
|
||||||
|
let windowStorage = MenuCollection { self.window }.getMenu(data: data, menu: app.windowsItem.submenu)
|
||||||
|
let helpStorage = MenuCollection { self.help }.getMenu(data: data, menu: app.helpItem.submenu)
|
||||||
scene.content[.mainContent] = [storage]
|
scene.content[.mainContent] = [storage]
|
||||||
scene.content["app"] = [appStorage]
|
scene.content["app"] = [appStorage]
|
||||||
|
scene.content["window"] = [windowStorage]
|
||||||
|
scene.content["help"] = [helpStorage]
|
||||||
return scene
|
return scene
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +84,12 @@ public struct MenuBar: MacSceneElement {
|
|||||||
if let content = storage.content["app"]?.first {
|
if let content = storage.content["app"]?.first {
|
||||||
self.app.updateStorage(content, data: data, updateProperties: updateProperties, type: MenuContext.self)
|
self.app.updateStorage(content, data: data, updateProperties: updateProperties, type: MenuContext.self)
|
||||||
}
|
}
|
||||||
|
if let content = storage.content["window"]?.first {
|
||||||
|
self.window.updateStorage(content, data: data, updateProperties: updateProperties, type: MenuContext.self)
|
||||||
|
}
|
||||||
|
if let content = storage.content["help"]?.first {
|
||||||
|
self.help.updateStorage(content, data: data, updateProperties: updateProperties, type: MenuContext.self)
|
||||||
|
}
|
||||||
guard let content = storage.content[.mainContent]?.first else {
|
guard let content = storage.content[.mainContent]?.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user