Hide a menu in windows

There is alot of confusing information about using menus in xojo. I have a need to hide a menu based on a security context. xojo does not seem to allow that.

This does not work, nor does using the visible property. The menu still shows up regardless. This code I have in the form.open event

if App.MyUser.isAdmin then
AdminMenu.Enable
AdminMenu.Enabled
end if

This is all documented https://documentation.xojo.com/api/deprecated/menuitem.html#menuitem-visible

Its too bad the code is not the same for windows/linux/mac. I would like to use the visible property.

I have it working in the simple scenario of if a user is an admin. However once you remove a menu, its gone and you cannot add it again, which is a shame.

Again, it would be good to have a working visible property.

As this exists I could never implement a logoff scenario as once the AdminMenu is removed it cannot be added in again. To get around that would be an unneeded hassle of having to keep a shadow menu in memory then code to manage that.

All platforms need the visible property.

Try this:

if App.MyUser.isAdmin then AdminMenu.Enabled = true AdminMenu.text = "Some menu text" else AdminMenu.Enabled = false AdminMenu.text = "-" end if

Jeff,
Interesting thought, but the menu still works just with a new title. The idea is to keep non-admins out of the config settings for the application. These settings are stored in the database and are system wide settings. Knowing my users I cant have them getting access to those.

You can, it’s just not quite as easy. If this menu updates frequently, consider creating it in code.

My understanding is that it’s related to API differences. If it were to happen today, macOS and Linux simply wouldn’t be able to remove menus so that the framework would match. We saw this with the updates to the FolderItem API, macOS lost the ability to track a file after it was moved to match the Windows and Linux frameworks.

No it doesn’t.
If you set the title to “-” it becomes a separator and unusable.
themenu.Enabled = false is just a second safety net