[SOLVED] Assigning double click to shape at runtime? lazarus / 39-Graphics ---------------------------------------------------------------------- AsleyCruz · 2020-04-12 23:16 Hi coders, The event OnClick on the shape works great. Is there any way to assign a new event "OnDblClick" to the shape at runtime? How can I do it? 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 var  aShape:Tshape;begin  aShape:=TShape.Create(nil);  with aShape do  begin    left:=3;    top:=3;    parent:=Form1;    width:=100;    height:=100;    shape:=stRectangle;    OnClick:= @TestClick;    OnDblClick:= @TestDoubleClick;  end;end; OnDblClick is not registered event: Error: identifier idents no member "OnDblClick". Many thanks in advance. ---------------------------------------------------------------------- lainz · 2020-04-12 23:24 You need to create a class that inherits from TShape and publish the property, since OnDblClick is not published for TShape. ---------------------------------------------------------------------- ASerge · 2020-04-12 23:57 Quote from: AsleyCruz on April 13, 2020, 01:16:29 amThe event OnClick on the shape works great. Is there any way to assign a new event "OnDblClick" to the shape at runtime? Both OnClick and OnDblClick are not published by TShape, but OnClick is public by default, but OnDblClick is protected. Use class helpers to get protected properties: 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 type  TSetOnDbkClickHelper = class helper for TControl    procedure SetDblClick(DblClickEvent: TNotifyEvent); inline;  end; procedure TSetOnDbkClickHelper.SetDblClick(DblClickEvent: TNotifyEvent);begin  OnDblClick := DblClickEvent;end; Test with TShape on Form OK: 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 type  TForm1 = class(TForm)    Shape1: TShape;    procedure FormCreate(Sender: TObject);  private    procedure ShapeDblClick(Sender: TObject);  end; //... procedure TForm1.FormCreate(Sender: TObject);begin//  Shape1.OnDblClick := nil;  Shape1.SetDblClick(@ShapeDblClick);end; procedure TForm1.ShapeDblClick(Sender: TObject);begin  Caption := 'Double click time ' + TimeToStr(Time);end; ---------------------------------------------------------------------- AsleyCruz · 2020-04-13 00:19 Quote from: ASerge on April 13, 2020, 01:57:13 amBoth OnClick and OnDblClick are not published by TShape, but OnClick is public by default, but OnDblClick is protected. Use class helpers to get protected properties: Thanks ASerge, problem was solved and worked like a charm. Many thanks.