What would prevent Enablemenuitem from firing?
My window I’ve checked has the menubar enabled but it doesn’t cycle through and these items are also disabled
Have you assigned a MenuHandler to each one?
Without that , they will never become enabled, as they have not been given a task to perform
Yes. That is in the enable menuitem section for the window. It doesn’t fire as in go into
Perhaps you’re misunderstanding how MenuBars / AutoEnableItems / MenuHandlers / EnableMenuItems works.
Here’s the Webinar on Menus: http://developer.xojo.com/webinar-menus
MenuHandlers are their own section… they define what to do if the menuItem is selected…
These cannot be defined inside EnableMenuItem,
- You have a Menu names “myMENU”… this you set up in the menu editor… there you provided a caption, and an optional hotkey
- Then you have to define a MenuHandler for “myMenu”… this is the code to execute when the user selects “myMenu”
- THEN in the EnableMenuItems event, you decide if myMenu is or is not active based on whatever logic you decide
but if you skip step #2, then Step #3 has no value
With other windows this piece of the window’s events normally fires and if I put a debugging stop in the enablemenuitems section of the window it will catch. Nothing happens with the window. It works fine in other windows. I can set conditions elsewhere and they work but nothing fires here.
For instance I have for code TableAddRowBelow.enable
Did you set this window’s MenuBar to the one you’re trying to use?
Windows default to MenuBar: None, but on Mac you never notice this.
I think I understand the setting you are referring to. The bottom of the window settings for the window has menubar uhmm used. It’s the correct bar. In this case menubarall is selected
- How many menu items do you have?
- How many menu handlers do you have?
- What code actually IN EnableMenuItems?
There are THREE different things, and I’m betting you are missing at least one
- The menubar connected to the WIndow (this is what Tim is referring to)
- one or more MenuItems on that MenuBar
- a MenuHandler connected to each MenuItem on the MenuBar
I have been away from my computer for a while.
I finally got the menubar to work by clicking on a Help item. It then shifted from the items that were enabled for the previous window to this set.
It then occurred to me that there was left over code in the menuitem that called this window.
PrefWindow.show// the new window
self.show// the calling window
I eliminated self.show and it worked immediately.
Sorry for having my bad code.
I have to eliminate stuff.