PrefsMenuItem value/text

Hi,
in my apps the value (text) of the PrefsMenuItem is set to “Preferences” thru a constant (kPrefs) taking care for localization.
Although my machine does not run Ventura, Ventura users of my apps report that the “Preferences” menu shows up as “Settings”. And I’am happy with that.

My problem is that if I have a Preferences window whose title is set to “Preferences”, I have to change that into “Settings”. So in the open event of that window I added:
title = editPrefs.value.replace(“…”, “”). In this way I hoped to get “Preferences” for pre-Ventura systems and “Settings” for Ventura.
But my Ventura testers tell me the window.title is still “Preferences” although they get “Settings” in the AppleMenu.

Is there any other way (declares?) to get the PrefsMenuItem’s “system” value/text in order to apply it somewhere else, without resorting to plugins or creating two constants, for instance, kPreferences for pre-Ventura, and kSettings for Ventura?
Thanks,

That’s the magic of Xojo. Your preferences menu item is of type DesktopPreferencesMenuItem (or the API1 equivalent), which automatically turns it to the preferences menu item at runtime (i.e.: move it to the  menu, set its caption to whatever the OS reports (and probably assign the command-, shortcut)). However, this is apparently an abstraction: the Xojo object is still as you defined in the menu editor (it just got assigned as a prefs item by some sort of “cloning”).

I’ve not found a way to automatically get the preferred window title of a preferences window. Instead, the Apple HIG (interface guidelines) state this: “if your app’s preferences window uses toolbar items, the window’s title should show the selected item. If not, it should show the app name.”.
Maybe this could interest you: Settings | Apple Developer Documentation

Arnaud, thanks for answering. I agree with what you say. By the way, the Prefs window of this particular app does not contain a toolbar, therefore I’m bound to set its title to Preferences/Settings.

So, I guess the only way will be to create a new constant for Ventura and assign it as the value of that menuitem when System.Version is >= 13.0

Pure guess…

Isn’t it possible to loop thru the Application Menu to know what’s in (the name) ?

The link I put above seems to suggest you should use simply the app name when the prefs window has no toolbar, not “Settings” nor “Preferences”. :man_shrugging:

It seems I’m not able to loop thru it:
dim m as menuitem = ApplicationMenuItem
dim s as string = m.MenuAt(1).Value

But I get an outofbound exception…

Yes, I noticed it, but what about pre-Ventura apps? IMO they’d expect the window-title as “Preferences”. And in such case I’d have to rely on System.version >= 13 to set the expected title.

But as it happens, the problem of Preferences window is not the only problem I have. For instance I may have a messageDialog saying something like: “Please refer to Preferences window”. Or a messageDialog with a “Preferences” button to open such window. And so on and so forth.

Dim MenuBar As New MainMenuBar

In the debugger, there is no AppleMenuItem nor ApplicationsMenuItem… (only File and Edit as defined in the project…).

Sorry.

Perhaps not… The link I gave doesn’t specifically talks about the new way.

In such cases, you won’t have much choices other than defining a dynamic string. Just put a property in the app class:
PrefsName as string

In the app’s opening event, define PrefsName as either “Settings” or “Preferences” based on the current running OS.
Then, in a message box, something like this: MessageBox “Please open the “+app.PrefsName.Lowercase+” window by going to the  menu.”

I was able to get the menu title of Safari preferences (“Einstellungen…” on my German OS) via AppleScript

tell application "System Events" to tell process "Safari" to get title of menu item 4 of menu 1 of (menu bar item 2 of menu bar 1)

To check it use Apple’s “Script Editor” and replace “Safari” with your App´s name.

You can call is as shown in this Post.

Make sure that your App has permissions to send Apple Events e.g. as shown in add a script in the Xojo Build

Actually, what they say is to name it like this:

App Name Settings

Hm… not for Safari or Apple Mail. On my German OS I have just “Einstellungen…” for both apps.
But it is not really new that Apple ignores its own rules :wink:

Well they are named “Human Interface Guidelines”. Not Rules or Requirements. And sometimes I’m pretty sure the development at Apple isn’t being done by humans anyway. :stuck_out_tongue_winking_eye:

Just checked Apple App Store app: in BigSur the preferences window is just “Preferences”.

Therefore I’ll go the way I outlined above, i.e. two constants (kPrefs = Preferences + other localized strings; and kPrefsVentura = Settings + localized strings) and apply them according to system.version >= 13.

I’d like to thank all who contributed to this topic.

1 Like