Forum > Cocoa
MainMenu: How to use the "Quit <App>" item that has been added in trunk?
Hansaplast:
I have noticed that, in trunk, when adding a TMainMenu to the main form, an application menu with a "Quit Application" menu item will be added.
Does anyone know where the use of this is documented or how it can be disabled?
In most of my application the "Quit" menu item and at times it does seem to work or conflict with my existing menu's (I use the Wiki documented method).
- How can I assign a procedure to the "Quit application menu" item (not listed in the menu editor)? In most applications it doesn't do anything (or conflicts).
- How do I add other menu items to this menu? After all it is not uncommon under macOS to add for example "Settings" or "Preferences" there as well.
- Worse case: how to disable this feature?
Or is this something I should report in Bug Tracker?
Note: I can see and appreciate the great intend and why it may be a good idea to add something like this, but maybe something needs to be documented or even be implemented slightly different? Or I'm just missing some info.
KodeZwerg:
I also use trunk but maybe a different version.
On my version I can not confirm your sayings.
This is how I do:
1. drop a TMainMenu on your Form.
2. doubleclick it to open the menu designer (image 1)
3. Design it
4. create events in object inspector by doubleclick the menu item (image 2)
Hansaplast:
KodeZwerg: you're right - the steps you're doing work the same for me as well.
But this wasn't the issue I meant to ask about. :)
Maybe I didn't explain myself properly. What I meant, is editing the predefined application menu, by adding items, or changing procedures.
Test 1:
When you make a new application, and you do not add a MainMenu, then when running the application and empty "project1" application menu will appear.
Test 2:
Same test, but now we add a MainMenu to the form, without adding any menu items!
Now when you run the application you will see that the application menu has a few predefined items (see my screenshot).
Some are predefined by macOS (Services, and the hide/show items) and one that has been added by Lazarus (Quit project1).
The issue I run into is that at designtime this automatically added menu is not shown in the menu editor, and I do not seem to have any easy options to add more items to the already existing "project1" menu, or change the "Quit" behavior.
So yes, I can add new menu's, each with whatever items I want. Those added menu's works as expected.
But I cannot add an item to the "project1" application menu (the one shown in the screenshot), or influence what clicking the "Quit project1" does.
In my applications I use the method described in the Wiki to add this application menu and I was able to freely add other items (as seen with other macOS applications).
For example:
I would add a menu item "Settings..." about the "Services" menu item ©mpare the screenshot from Lazarus and my previous screenshot).
So what is the recommended method to do this?
Also: how can I assign a procedure to the "Quit project1" menu item?
wp:
I am not a mac-specialist, but I am afraid that you cannot modify this menu (at least not within the framework of the LCL) since it seems to be created by the OS.
Hansaplast:
Thanks for chiming in wp. It's much appreciated.
However, you can modify parts of this menu, as described in the Wiki (link).
I was just wondering if there could be a better way to do this.
Thanks all for chiming in. Maybe I can come up with something myself 😊 (I'll share if I do)
Navigation
[0] Message Index
[#] Next page