Skip to content

Commit

Permalink
Merge pull request #806 from SergejDK/fix/696
Browse files Browse the repository at this point in the history
Fix: Add native main menu to MacOS template
  • Loading branch information
TimLariviere authored Sep 23, 2020
2 parents 5365773 + 6383426 commit fe51759
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AppDelegate() =

override this.DidFinishLaunching(notification: NSNotification) =
Forms.Init()
this.SetupNativeMenu()
this.LoadApplication(new NewApp.App())

base.DidFinishLaunching(notification)
Expand All @@ -29,6 +30,21 @@ type AppDelegate() =

override __.ApplicationShouldTerminateAfterLastWindowClosed(_) = true

member this.SetupNativeMenu() =
let menuBar = new NSMenu()
let appMenuItem = new NSMenuItem()
menuBar.AddItem(appMenuItem)

let appMenu = new NSMenu()
appMenuItem.Submenu <- appMenu

let quitMenuItem = new NSMenuItem(sprintf "Quit %s" window.Title, "q", EventHandler(fun _ _ ->
NSApplication.SharedApplication.Terminate(menuBar)
))
appMenu.AddItem(quitMenuItem)

NSApplication.SharedApplication.MainMenu <- menuBar

module EntryClass =
[<EntryPoint>]
let Main(args: string[]) =
Expand Down
2 changes: 1 addition & 1 deletion docs/Fabulous.XamarinForms/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ match model.IsLoggedIn with
Platform-specific dispatch
-----

Some platform-specific features (like deep linking, memory warnings, ...) are not available in Xamarin.Forms, and need you to implement them in the corresponding app projet.
Some platform-specific features (like deep linking, memory warnings, ...) are not available in Xamarin.Forms, and need you to implement them in the corresponding app project.
In this case, you might want to dispatch a message from the app project to Fabulous to start a shared logic between platforms (to warn user, ...).

To allow for this kind of use case, the `dispatch` function is exposed as a `Dispatch(msg)` method by the `ProgramRunner`. By default this runner is not accessible, but you can make a read-only property to let apps access it.
Expand Down

0 comments on commit fe51759

Please sign in to comment.