Explorar o código

TFresnelViewport: register events on first instance

mattias %!s(int64=2) %!d(string=hai) anos
pai
achega
3302eeb85f
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      src/fresnel.dom.pas

+ 8 - 0
src/fresnel.dom.pas

@@ -568,6 +568,8 @@ type
     FWidth: TFresnelLength;
     FMaxPreferredWidth: TFresnelLength;
     procedure CSSResolverLog(Sender: TObject; Entry: TCSSResolverLogEntry);
+  protected
+    class var FFresnelEventsRegistered: boolean;
   protected
     function GetDPI(IsHorizontal: boolean): TFresnelLength; override;
     function GetHeight: TFresnelLength; virtual;
@@ -1569,6 +1571,12 @@ begin
   FCSSResolver.OnLog:=@CSSResolverLog;
   FStylesheet:=TStringList.Create(false);
   FStylesheet.FPOAttachObserver(Self);
+
+  if not FFresnelEventsRegistered then
+  begin
+    FFresnelEventsRegistered:=true;
+    TFresnelEventDispatcher.RegisterFresnelEvents;
+  end;
 end;
 
 { TFresnelElement }