From 108b40651d2775a6cbe06060329fd32f2d9ef7b9 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Wed, 30 Mar 2022 13:57:24 +0200 Subject: [PATCH] More macOS menu bar improvements --- lib/livebook_app.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/livebook_app.ex b/lib/livebook_app.ex index edf9e8e52..707b9e472 100644 --- a/lib/livebook_app.ex +++ b/lib/livebook_app.ex @@ -41,12 +41,12 @@ if Mix.target() == :app do wx = :wx.new() frame = :wxFrame.new(wx, -1, app_name, size: size) + :wxFrame.show(frame) if os == :macos do fixup_macos_menubar(frame, app_name) end - :wxFrame.show(frame) :wxFrame.connect(frame, :command_menu_selected, skip: true) :wxFrame.connect(frame, :close_window, skip: true) @@ -122,8 +122,15 @@ if Mix.target() == :app do defp fixup_macos_menubar(frame, app_name) do menubar = :wxMenuBar.new() :wxFrame.setMenuBar(frame, menubar) + menu = :wxMenuBar.oSXGetAppleMenu(menubar) + # without this, for some reason setting the title later will make it non-bold + :wxMenu.getTitle(menu) + + # this is useful in dev, not needed when bundled in .app + :wxMenu.setTitle(menu, app_name) + menu |> :wxMenu.findItem(@wx_id_osx_hide) |> :wxMenuItem.setItemLabel("Hide #{app_name}\tCtrl+H")