Having a problem on Windows when hiding a menu item, setting it to visible = false.
The style of the menu changes.
from
to
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 NilObjectException.
[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)
[/quote]
All I can tell you the docs state that it’s not available. I misunderstood your post the first time I read it. http://documentation.xojo.com/index.php/MenuItem.Visible
But now that I do understand it sounds like you’re having an issue with an unsupported property.
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.
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.
[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?
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.
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.