There aren’t a lot of items in a Xojo desktop project that you can’t rename. You can change the name of the App instance, the default window, the default menu bar and many many others.
But there are a handful that, if you do rename them, you may inadvertently break your application. This is entirely due to how the Xojo framework works, and in part how macOS itself works.
One group of items you should not rename is several Edit Menu items. Do not rename EditCut, EditPaste, EditClear, and EditSelectAll. The reason is, that if you do, then certain classes in the Xojo framework will no longer handle those menu items by default.
The simplest demo of this is to
- start a new desktop project
- add a TextArea to the default window – Window1
- run
Now if you type in text to the text area and press the shortcut for Select All (⌘-A or Ctrl-A) the text area will automatically handle selecting all the text.
Quit your little demo app and in the menu editor rename EditSelectAll to MyEditSelectAll.
Run the small sample again. Perform the same test by adding a bunch of text and trying to use the shortcut. This time the menu shortcut is NOT automatically handled and likely just beeps at you.
Several controls have behaviour that is pre-configured to rely on the Edit Menu items being named in a specific way. I’ve written about how you can do this as well before. Renaming the Edit Menu items then breaks that automatic configuration.
The other thing that renaming is specific to macOS. On macOS the OS will automatically add new menu items, the ones for Start Dictation and Emoji & Symbols, to the edit menu IF it the TEXT of the for the Edit Menu title is “Edit”.
If you alter it to anything else then macOS will not find the correct menu to insert these items and they will not be added to your Edit Menu.
Again this is easy to test with the tiny sample app we have so far. Just change the Edit menus text to Edit followed by a space and run. When you click on the Edit menu you will not longer have the 2 automatically added items.
Woah! That’s huge. Thank you for pointing that out. I hope I remember.
and it’s far worse on non english macos !
I have no doubt there are at least as many things to worry about on non-English systems.
macOS itself seems to rely on the names in English for some automatically added menu items.
Another magic menu name on macOS is “View”. Menus named “View” will have a few menu items (“Enter Full Screen”, some tab-related behaviors) inserted automatically.
As with Edit, renaming to “View ” disables the extra menu items.
I have found that the extra space in the menu name is visually noticeable in the menu bar if you have additional menus to the right of the renamed menu. You can fix this at App.Open or later by manually setting the menu name back to the non-spaced version; this seems to be late enough in the process that macOS won’t mess with them anymore.
Be aware that this fix does cause a brief visual tic at startup. To my mind that’s less of a problem than the extra space between menus. Might be able to avoid that by starting up with a dummy menubar and then swapping in the real menubar after removing the space, but I haven’t tried that yet.