Xojo2018r4. This happens on MacOS 64-bits, both in Debug and compiled. Haven’t checked Windows behaviour yet.
In the App Enablemenuitems event, I call a short method that enables or disables some of the menuitems.
The first time I click on a menu item, nothing is enabled, which isn’t right. I click on it again, and then things are enabled or disabled as they should be.
This is repeatable, happens the same way every time. The first time the menu is opened, it’s as if the method enabling or disabling the menu items simply wasn’t called; nothing is enabled. The second time things work as they should.
Is this a known issue? Is there a workaround? It’s annoying. I couldn’t find it in feedback.
How many windows do you have open?
Maybe another window which lacks such code has ‘owned’ the event first.
What you are seeing is what you get if the App has control, rather than the window.
Maybe if you ensure the window has focus? What kind of window is it?
No offense… but there IS a logical explanation, you just haven’t found it…
and if you are going to shoot at every suggestion, then help might become hard to find.
Since none of us have seen a lick of your code, all we can do it suggest things that could contribute to your issue, having no idea if you have or have not considered the suggestion before hand.
and with that … I wish you good luck… and have a nice day
AutoEnable can override manual enabled state settings. It’s not a bug, you need to turn AutoEnable off if you’re going to manually manage the enabled state.
In the docs for the MenuItem.Enabled event it says: For MenuItems that belong to an App or Window menu, this property should only be set to True in the EnableMenuItems event handler.
I changed your code in EnableMenuItems to the following and it works as you expect.
if CheckBox1.Value then
TestMenu.Enabled = True
TestEnableMe.enabled = True
end
It works whether AutoEnable is on or off. I always leave it off when I am enabling this way.
The problem appears to be that EnableMenuItems is fired at weird times on Mac, compared to Windows. Like, it fires when inputting keystrokes into a TextField. Why? Who knows, but this must be the reason for the (totally unsubstantiated) recommendation to only set that property to true in the EnabledMenuItems event, which also only seems to be necessary on Mac, since not respecting that recommendation has no effect on Windows.
It’s not surprising that things work different on Windows than the Mac. Also, I’m sure you know that event sequence order is not to be relied on. I do all my coding on the Mac and test on the Mac, then Windows. So I suppose I’ve never had the opportunity to run into this problem.
The main thing is you can make a minor change and you’ll get what you want. This way will work in Windows also.
And… where I’m from, if you tell someone you’ll be happy to take their money, that’s the same as accepting the bet…