polymerchm
polymerchm

Reputation: 228

How to customize the "about App" menuitem

I've successfully ported my Chord calculus app to Mac Catalyst, with working key commands, context menus and multiple scenes. Can even screen capture the fretboard to the clipboard for developing tutorial content. Still working on saving it to a file, but have gotten the DocumentView working, so it's just grunt work to finish that.

I am currently working on mode-dependent main menu items. I am wanting to change the simple "about App" menu item, but it's not clear what to do. I can replace it with the builder.replace() method, but I get a menu pointing to a submenu. Would like a simple button to generate an "alert" type response. Suggestions?

Upvotes: 1

Views: 371

Answers (3)

Nik Bhatt
Nik Bhatt

Reputation: 373

Building on the previous answer, you can also get the localized title for the existing About menu like this:

var aboutTitle = "About <myapp>"
if let existAbout = builder.menu(for: .about),
   let menuItem = existAbout.children.first {
    aboutTitle = menuItem.title
}

add your action and then

builder.replace(menu: .about, with:
  UIMenu(title: "", image: nil, identifier: .about,
    options: .displayInline, children: [action]))

Upvotes: 0

polymerchm
polymerchm

Reputation: 228

let action = UIAction(title: "about Chord Calculus", handler: {
  par in
  print("test action")
})

builder.replace(menu: .about, with:
  UIMenu(title: "", image: nil, identifier: .about,
    options: .displayInline, children: [action]))

Upvotes: 1

Adam
Adam

Reputation: 5145

Try using replaceChildren(ofMenu:from:) with .application, which is the About menu item’s parent. The closure will give you the list of children, one of which should be .about, and you can return a new list with your replacement.

That said, you can customize the default About box by providing a Credits.rtf file, which might be all you need: https://blog.kulman.sk/editing-macos-app-about-dialog/

Upvotes: 2

Related Questions