Recent

Author Topic: How to Add a MenuItem to the top level menu of lazarus IDE?  (Read 1828 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: How to Add a MenuItem to the top level menu of lazarus IDE?
« Reply #15 on: August 13, 2022, 05:30:41 pm »
At what time to you call RegisterIDESubMenu?

It should be in the "register" procedure. (Which is called at some time by the IDE)
(You have that in your original example... but just checking)

If you put it into some initialization section, it likely wont work.

------- EDIT:
Or well, double check it.
Code: Pascal  [Select][+][-]
  1. assert(mnuMain<>nil);
-Sa
« Last Edit: August 13, 2022, 05:51:33 pm by Martin_fr »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: How to Add a MenuItem to the top level menu of lazarus IDE?
« Reply #16 on: August 13, 2022, 06:09:56 pm »
If what needed to be done is this....   it didn't work.
Code: Pascal  [Select][+][-]
  1. begin
  2.   vSect := RegisterIDESubMenu(mnuMain,'mniJFrameworkMainMenu','Jota Framework');
  3.   RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizard','Abrir JFW Manager [Ctrl+M]', nil, @OpenJFWManager);
  4. end;
Here the exact verbatim same code works. I test by modifying the ToDoList package's Register procedure, but that should make no difference.
Only the "(Sender as TComponent).Name" in your OnClick handler gives an error about a wrong typacast. Use "Sender.ClassName" to see what type it is.
« Last Edit: August 13, 2022, 08:48:55 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
Re: How to Add a MenuItem to the top level menu of lazarus IDE?
« Reply #17 on: August 13, 2022, 08:23:14 pm »
You are right..

I don't know what happened before.


Tested again and it worked....

I want to thank you all for the help.

I Really apreciate it!

If what needed to be done is this....   it didn't work.
Code: Pascal  [Select][+][-]
  1. begin
  2.   vSect := RegisterIDESubMenu(mnuMain,'mniJFrameworkMainMenu','Jota Framework');
  3.   RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizard','Abrir JFW Manager [Ctrl+M]', nil, @OpenJFWManager);
  4. end;
Here the exact verbatim same code works. I test by modifying the ToDoList package's Register procedure, but that should make no difference.
Only the "(Sender as TComponent).Name" in your OnClick handler gives an error about a wrong typacast. Use "Sender.ClassName" to see what type it is.
« Last Edit: August 13, 2022, 08:50:44 pm by JuhaManninen »
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: How to Add a MenuItem to the top level menu of lazarus IDE?
« Reply #18 on: August 13, 2022, 09:28:25 pm »
To make it work I had to select the unit1 file in the package manager and check the register unit checkbox. See attached screenshot. I'm guessing the register procedure never executed.

 

TinyPortal © 2005-2018