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.
|
||||
func windowsMenu() {
|
||||
let windowsMenu = NSMenu()
|
||||
mainMenu.addItem(windowsItem)
|
||||
windowsItem.submenu = windowsMenu
|
||||
app.windowsMenu = windowsMenu
|
||||
}
|
||||
@ -58,18 +57,24 @@ public class MacApp: AppStorage {
|
||||
/// The help menu.
|
||||
func helpMenu() {
|
||||
let helpMenu = NSMenu()
|
||||
mainMenu.addItem(helpItem)
|
||||
helpItem.submenu = helpMenu
|
||||
app.helpMenu = helpMenu
|
||||
}
|
||||
|
||||
/// Add the windows and help menus.
|
||||
func addMenus() {
|
||||
mainMenu.addItem(windowsItem)
|
||||
mainMenu.addItem(helpItem)
|
||||
}
|
||||
|
||||
/// Execute the app.
|
||||
/// - Parameter setup: Set the scene elements up.
|
||||
public func run(setup: @escaping () -> Void) {
|
||||
appMenu()
|
||||
setup()
|
||||
windowsMenu()
|
||||
helpMenu()
|
||||
setup()
|
||||
addMenus()
|
||||
app.run()
|
||||
}
|
||||
|
||||
|
||||
@ -59,9 +59,14 @@ public struct MenuBar: MacSceneElement {
|
||||
let scene = SceneStorage(id: id, pointer: app.mainMenu) { }
|
||||
let data = WidgetData(sceneStorage: scene, appStorage: app)
|
||||
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 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["app"] = [appStorage]
|
||||
scene.content["window"] = [windowStorage]
|
||||
scene.content["help"] = [helpStorage]
|
||||
return scene
|
||||
}
|
||||
|
||||
@ -79,6 +84,12 @@ public struct MenuBar: MacSceneElement {
|
||||
if let content = storage.content["app"]?.first {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user