Event value disappeared in the object inspector lazarus / 10-Designer ---------------------------------------------------------------------- alpine · 2024-02-14 15:31 I have a component containing an event property with a setter. When I install the component into the IDE, the property value disappears each time when I reload the project. Consider the following source (example package and project attached): 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 Shape1; {$mode ObjFPC}{$H+} interface uses  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls; type   { TShape1 }   TShape1 = class(TShape)  private    FOnWhatever: TNotifyEvent;    procedure SetOnWhatever(AValue: TNotifyEvent);  public    procedure DoWhatever;  published    property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;  end; procedure Register; implementation procedure Register;begin  {$I shape1_icon.lrs}  RegisterComponents('Misc',[TShape1]);end; { TShape1 } procedure TShape1.SetOnWhatever(AValue: TNotifyEvent);begin  if FOnWhatever=AValue then Exit; // <--- Comment this, troubles the obj.inspector  FOnWhatever:=AValue;end; procedure TShape1.DoWhatever;begin  if Assigned(FOnWhatever) then    FOnWhatever(Self);end; end.The example project compiles and works as expected, i.e. the event property have the proper value, only it is lost into the object inspector. When I comment line #38 above, the issue disappears. Anyone have  an idea? Found this: https://forum.lazarus.freepascal.org/index.php/topic,29609.0.html but no explanation there. My Laz is rather old, but anyway: Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-linux-gtk2. ---------------------------------------------------------------------- Thaddy · 2024-02-14 16:36 maybe: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 property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;stored;And or compile the new class in{$M+} state.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 //snip  {$M+}  TShape1 = class(TShape){$M+} is a local directive, so you should define it anyway on a per unit and/or per class basis. ---------------------------------------------------------------------- alpine · 2024-02-14 16:56 Quote from: Thaddy on February 14, 2024, 05:36:01 pmmaybe: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 property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;stored;And or compile the new class in{$M+} state.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 //snip  {$M+}  TShape1 = class(TShape){$M+} is a local directive, so you should define it anyway on a per unit and/or per class basis. Thanks for the reply! However, the property value is stored. I can see it into the .lfm text. It is also loaded properly, since when rebuilt the executable works as expected, i.e. the event handler is called. IMHO the issue is in the object inspector itself. It simply does not display the property value after the project reload. ---------------------------------------------------------------------- Josh · 2024-02-14 17:11 have you tried uninstalling/removing your component from the ide, making sure you rebuild and restart the ide to complete the removal. Then re-install the component and rebuild and restart the ide. ---------------------------------------------------------------------- Thaddy · 2024-02-14 17:20 Yes, if it is a component you need to rebuild the ide, but do not forget {$M+} ---------------------------------------------------------------------- alpine · 2024-02-14 17:38 Quote from: Josh on February 14, 2024, 06:11:44 pmhave you tried uninstalling/removing your component from the ide, making sure you rebuild and restart the ide to complete the removal. Then re-install the component and rebuild and restart the ide. I haven't tried exactly that, but since I'm modifying an existing and installed package, I'm constantly doing a "Build Lazarus with Profile:" on each change. When I experienced troubles, I have installed the package on my Winbox Lazarus (currently I'm on Linux) and there the behavior was the same. Then I've made a small, isolated package - the one attached - and tried it on both Win/Linux installations - again - the same. About the {M+} - it is not the only property in the original component, I believe that without RTTI no property will be shown at all in the inspector, and all the components are TPersistent descendants - docs says the {M+} is implied. ---------------------------------------------------------------------- Thaddy · 2024-02-14 18:13 You HAVE to rebuild the Lazarus IDE. There is no option yet to get around that. There will be in the future. ---------------------------------------------------------------------- wp · 2024-02-14 18:29 In TAChart there's this: 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 procedure TChart.SetOnAfterCustomDrawBackground(AValue: TChartAfterCustomDrawEvent);begin  if TMethod(FOnAfterCustomDrawBackground) = TMethod(AValue) then exit;  ...end; When I apply this (and implement the TMethod compare operator) your component works: 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 operator = (const A, B: TMethod): Boolean;begin  Result := (A.Code = B.Code) and (A.Data = B.Data);end; procedure TShape1.SetOnWhatever(AValue: TNotifyEvent);begin  if TMethod(FOnWhatever) = TMethod(AValue) then exit;  FOnWhatever:=AValue;end; ---------------------------------------------------------------------- n7800 · 2024-02-14 18:45 I just wanted to give a link: https://wiki.freepascal.org/IDE_tricks#Events_.28Method_properties.29_ in_the_Object_Inspector ---------------------------------------------------------------------- alpine · 2024-02-14 21:08 Quote from: n7800 on February 14, 2024, 07:45:14 pmI just wanted to give a link: https://wiki.freepascal.org/IDE_tricks#Events_.28Method_properties.29_ in_the_Object_Inspector Thanks, that makes the things clear. I didn't know it. @wp No matter how confident I can feel, there is always something more that can be learned. It's not an important one but it is of those that can ruin your whole afternoon. Thanks a lot, pal. ---------------------------------------------------------------------- Bart · 2024-02-14 21:54 B.t.w.: for events it's rather customary to have it like: 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   property OnSomething: TNotifyEvent read FOnSomething write FOnSomething; Bart