Forum > Designer

Event value disappeared in the object inspector

(1/3) > >>

alpine:
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  [+][-]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 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:
maybe:
--- 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";}};} ---property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;stored;And or compile the new class in{$M+} state.
--- 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";}};} ---//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:

--- Quote from: Thaddy on February 14, 2024, 05:36:01 pm ---maybe:
--- 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";}};} ---property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;stored;And or compile the new class in{$M+} state.
--- 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";}};} ---//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.

--- End quote ---
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:
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:
Yes, if it is a component you need to rebuild the ide, but do not forget {$M+}

Navigation

[0] Message Index

[#] Next page

Go to full version