Forum > General

How to Add a MenuItem to the top level menu of lazarus IDE?

(1/4) > >>

LeoBruno:
HI:

I need to create a ManuItem to the top level menu of the IDE, and some other inside the created menu.

How to achieve this?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- unit Model.IDE.Menu; {$mode objfpc}{$H+} interface uses  Dialogs,  MenuIntf,  Classes,  SysUtils;  procedure Register; procedure OpenJFWManager(Sender: TObject); implementation procedure Register;begin  RegisterIDEMenuCommand(mnuMain, 'mniJotaIdeWizardsMainMenu','&Jota Framework', nil, nil);  RegisterIDEMenuCommand('mniJotaIdeWizardsMainMenu', 'mniJotaIDEWizardsOpenProjectManager', 'Abrir JFW Manager', nil, @OpenJFWManager);end; procedure OpenJFWManager(Sender: TObject);begin  ShowMessage('test!!!');end; end.  
The first line of the Register procedure the intetion was to create a MenuItem at the top level menu (sibling of "File", "Edit", "View"...)
The second line, should create another Menu, children of the MenuItem created above.

Any tips?

Thank's

HeavyUser:
https://wiki.lazarus.freepascal.org/Extending_the_IDE#Menu_items

LeoBruno:
Thank you.

I used that documentation to write the code above, but I missed something, because it didn't work.

The top level menu didn't show, and thus, so it's children.



--- Quote from: HeavyUser on August 13, 2022, 12:16:12 am ---https://wiki.lazarus.freepascal.org/Extending_the_IDE#Menu_items

--- End quote ---

HeavyUser:

--- Quote from: LeoBruno on August 13, 2022, 01:39:41 am ---Thank you.

I used that documentation to write the code above, but I missed something, because it didn't work.

The top level menu didn't show, and thus, so it's children.



--- Quote from: HeavyUser on August 13, 2022, 12:16:12 am ---https://wiki.lazarus.freepascal.org/Extending_the_IDE#Menu_items

--- End quote ---

--- End quote ---
have you tried calling

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function RegisterIDEMenuRoot(const Name: string; MenuItem: TMenuItem = nil                             ): TIDEMenuSection;  and build under that your menu?

PS. I would leave the MenuItem nill for the first tests.

LeoBruno:
Well I managed to get the First Menu (the top level).

The problem now is creating the children inside it.

in other words, this works:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Register;begin  RegisterIDEMenuCommand(mnuMain, 'mniJFrameworkMainMenu','&Jota Framework', nil, nil);   end; 
Now, I guess that the code above is creating a TIDEMenuCommand whith the name 'mniJFrameworkMainMenu'.

I'm trying to create the children, using the other overloaded method, passing the 'mniJFrameworkMainMenu' as the path parameter.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Register;begin  RegisterIDEMenuCommand(mnuMain, 'mniJFrameworkMainMenu','&Jota Framework', nil, nil);  RegisterIDEMenuCommand('mniJFrameworkMainMenu', 'mniJFrameworkOpenProjectManager', 'Abrir JFW Manager', nil, @OpenJFWManager);  end; 
The second line doesn't work, Lazarus doesn't open. (Err. Msg: IDE Path Menu not found).








--- Quote from: HeavyUser on August 13, 2022, 02:40:12 am ---
--- Quote from: LeoBruno on August 13, 2022, 01:39:41 am ---Thank you.

I used that documentation to write the code above, but I missed something, because it didn't work.

The top level menu didn't show, and thus, so it's children.
--- End quote ---

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version