Having a problem on Windows when hiding a menu item, setting it to visible = false.
The style of the menu changes.
Removing them is fine but i don’t want to have to add and remove the items.
I have sent in a feedback, but i was wondering if anyone knows how to hide a menu item on windows without this happening.
If i set an item invisible on window open, app open, window enablemenustates events, they all cause the problem.
Happens on Xojo 2016r3, 2017r2.1 and 2017r3, compiled on OSX for Windows.
Per the documentation, the
Visible property is not available on Windows. This is expected.
Because the Windows paradigm allows different windows to have different menubars you can use different menubars on Windows when certain items aren’t relevant.
I try to aim for one menubar, and removing platform specific items in App.Open. Doing it here prevents a situation where the removal might occur twice and the second time would cause a
If the property is not available on windows why does it still hide the menu item? (and change the look and feel of the menu bar)
[quote=376994:@Graham Busch]If the property is not available on windows why does it still hide the menu item? (and change the look and feel of the menu bar)
All I can tell you the docs state that it’s not available. I misunderstood your post the first time I read it.
But now that I do understand it sounds like you’re having an issue with an unsupported property.
Xojo rebuilds the menu for you without the invisible ones.
And the rebuild menu is in older style.
So the only way around this would be to remove the menu item, keeping a local property to stop the menu item being cleaned up, and then inserting it back in when it needs to be shown.
No, you could have two menu bars and switch between them by assigning window.menubar property.
I would say that’s a terribly confusing user experience. You should not modify a menus items once they’re presented to the user. Enabling and disabling as necessary, sure. But removing and adding adds to confusion, and means they can’t locate items easily.
There is an alternative way of swapping menubars on the fly, but then you’ll have different menubar objects in your project for different states of the menus. I don’t recommend the alternative, but it’s available.
Edit: Beaten by just a few seconds! I included my opinion on how you’re handling the menus though.
We have a lot of menu items, having two menus (would actually have to be 4 to support the preference driven options) would be a nightmare to code the handlers against.
Hiding and showing menu’s is only down based on preferences or current registrations, it’s not happening constantly. Not sure why you are saying it such a bad item, don’t Microsoft automatically hide menu items in office? that being said that was awful.
I think adding and removing them is the only way to go, as there are only a few items to manage.
You can also disable them.
How about change the text to “-” making them into separators?
A good menu shows all the items and only disables what is currently not available.
Only if you switch from one part of the app to another, e.g. from spreadsheet to word processor in Office app, you get a new menu.
[quote=376998:@Christian Schmitz]Xojo rebuilds the menu for you without the invisible ones.
And the rebuild menu is in older style.[/quote]
Isn’t that what’s usually called a bug? And therefore he should open a feedback report?
of course @Graham Busch could report the behavior as a bug/problem.
But if Windows doesn’t allow to hide existing menu items and you need to rebuild the menu, it could be called a bug to use older style.
AFAIK you can hide menuitems in the enableMenuItem event only.
Btw what happens if you set MenuItem.Enabled as well? See bug report <https://xojo.com/issue/33462>
I just set a MenuItem as disabled (in App.EnableMenuItem) because the feature is not “public” ready.
Works fine on macOS (appears disabled), but I do not have a Windows machine handly (now) to test it, yet.
I’ve got to get out my pitchfork here. Swapping menus around (hiding/showing/removing) on Windows windows (windows windows windows) is just a terrible thing.
As others have said, it creates a confusing interface for users. The proper way is always to Enable/Disable. It’s better that a user question why the item is disabled and look for an answer, than realize what they’re looking for has just magically disappeared with no reason. At that point they can lose trust in the UI.
That said, this does appear to be a bug, and the discussion isn’t about UI best practices. I would report this issue in Feedback.
The only way is to Clone it into a temporary MenuItem then Remove it and Insert it back in when you want it shown. That is the way its done according to MSDN, there is no hide flag in windows.
Seems odd that the framework doesn’t just wrap all that up for you or they tried and found a problem and just left it where it was producing that odd looking menu.