I am new here

I do not have any menu with name “MenuBarSelected”, my menu bar name is “MainMenuBar”.
At the top of the project list there is the App and you can add a Menu Handler.
Then at the right I can select some of my existing menu items and there is a code that says

Return True

Do I am writing something there?

MenuBarSelected is the rename of the EnableMenuItems event. You need to add an Event Handler at the appropriate level (Window or App) and then enable / disable menu items within that handler.

Menu Handlers are called when an actual menu item has been selected. If you have AutoEnabled on for a particular menu item, that menu item is enabled when there is a handler for it.

I’ve been looking for a good example to help you out, but there don’t seem to be any. Not in the Example Projects folder, not in the Introduction to Xojo Programming textbook. So much of our institutional knowledge has been lost.

I still not understand.
Maybe I am not giving details.
I have one menu at my main window with name “MainMenuBar”
This “MainMenuBar” has 3 menus. “fileMenu”, “settings” and “monsters”
The “fileMenu” has some submenu items
“new_Adventure”,“save_Adventure”,“load_Adventure”
The “monsters” menu have no items

In the visual Basic usually we called a simple single command MainMenuBar.fileMenu.New_Adventure.Enabled = True
Why here do we need so many complexities?

When you have a menu defined, each menu item has a name.
One of mine is called mnuReCalculate, for example.

The App can handle these, if the menu does not need to know about what is happening on a window.
Examples might be File/new , or Preferences

If it makes more sense for the Window to handle the menu (example would be ‘Redraw’, ‘Paste’, "copy’), then the Window needs a menu handler for that menu

Let us say the Window has to handle settings
Right click on the Window in the IDE, and add menu handler
Select the settings menu, and it will give you an empty event handler
It has ‘return True’ by default - if you leave that in, only this window will get the event -( true means ‘I did all that was needed’)

When your app runs, if the window is open, the menu settings will be enabled.
If the window is not open, the App has no handler for that menu, and it will be disabled.

They could BOTH have an event handler.
If so, the window will do the work, and the App will not get the message
If the window is missing, then it is the App that gets the job.

I added a menu handler for the “new_adventure” menu item but the menu wasn’t enabled.
I still do not understand.

To the App, or to a window?
Try adding an event handler for
EnableMenuItems

and put New_Adventure.Enabled = True
into that.

Well, showing another video I understood that, if there is NO code in the menu handlers. There that I asked what I will write, if I will add some code then the menu is enabling. for example I added the command to show my second window I have. Then the menu was enabled.
So my menus are always disabled because there wasn’t any code in their event handlers.
This was the thing you not given me to understand.
I thought that I am able to enable and disable the menus even if there is not code inside their handlers. (Like the visual Basic did).

Well, things are getting revealed.
Now I understood. Previously you said to select the “MenuBarSelected” but this wasn’t my MenuBar name but was the name of an event.
I found it when I tried to add a window event handler not menu handler.

What do I will do if I will need to enable or disable a ToolBar menu item?
Well I found it, I created an opening handler in my ToolBar11 and I added this.

Toolbar11.quests_Button.Enabled = false

My quest_Button from my ToolBar11 was disabled.

New question.
How do I will change some color from a gadget.
For example let say the color of a button or the text or change the font?
Something more advanced, it is possible to change the whole theme?

Start a new topic for new questions.

2 Likes

They are native controls, so not every aspect can be customized. For complete control you’re going to have to draw everything yourself.

I thought if I have all my questions here will save space in the forum.
I will open a new topic for the next question.

1 Like

It’s easier to see if a question has been answered if each problem is a separate topic. When you see a good answer, you can click on the Solution button below the reply.

5 Likes

Also will create a historical content mess for future users looking for solutions to the same questions you had. People use the search field before asking things already asked in the past, and they get the solution faster (those marked). When they don’t find one, they create another topic with a new question and a new solution.

3 Likes

Also, use descriptive titles for your topic, such as “How do I change the font on a control?”

2 Likes

There is no shortage of space and as others have said. Having a question with a good name allows others looking for the answer to the same problem to find it easily.

Please do it for this one. As you can see nobody wants to add to a large chaotic thread.