Popup Menu cannot set on onClick event lazarus / 21-General ---------------------------------------------------------------------- Raf20076 · 2021-01-21 09:58 Hi Guys I cannot go through with this. I want to create kind of popup menu dinamiacally with onClick event but I get errors. Compile Project, Target: C:\Users\Dom\AppData\Local\Temp\project1.exe: Exit code 1, Errors: 2 unit1.pas(42,33) Error: Wrong number of parameters specified for call to "PopupMenuItemsClick" unit1.pas(19,15) Error: Found declaration: PopupMenuItemsClick(TObject); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus; type   { TForm1 }   TForm1 = class(TForm)    Memo1: TMemo;    Memo2: TMemo;    PopupMenu1: TPopupMenu;    procedure FormCreate(Sender: TObject);    procedure PopupMenuItemsClick(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject);varNewItem : TMenuItem;Popupword :String ;begin             Popupword := 'ddddddd';             NewItem := TMenuItem.Create(PopupMenu1);             PopupMenu1.Items.Add(NewItem);             NewItem.Caption := Popupword;             NewItem.OnClick := PopupMenuItemsClick; // Assign it an event handler.          end;  procedure TForm1.PopupMenuItemsClick(Sender: TObject);begin       ShowMessage('item clicked');      end;end.    Thanks ---------------------------------------------------------------------- wp · 2021-01-21 10:05 In mode objfpc you must use the @ operator to assign a procedure to the event handler: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i NewItem.OnClick := @PopupMenuItemsClick; Alternatively you can use mode Delphi instead of objfpc Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //{$mode objfpc}{$H+}{$mode Delphi} ---------------------------------------------------------------------- Raf20076 · 2021-01-21 10:14 Quote from: wp on January 21, 2021, 11:05:48 amIn mode objfpc you must use the @ operator to assign a procedure to the event handler: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i NewItem.OnClick := @PopupMenuItemsClick; Alternatively you can use mode Delphi instead of objfpc Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //{$mode objfpc}{$H+}{$mode Delphi} Thanks a lot it works.