Function Pointer property



Function Pointer property
Smart pascal source code
type TNotifyEvent = Procedure(sender: TObject); type TMyObject = Class(TObject) private FEvent: TNotifyEvent; Procedure setEvent(Value: TNotifyEvent); public Property OnClick: TNotifyEvent read FEvent write setEvent; procedure Trigger; End; Procedure TMyObject.setEvent(Value: TNotifyEvent); Begin FEvent := Value; end; procedure TMyObject.Trigger; begin if Assigned(FEvent) then FEvent(Self); end; Procedure HandleEvent(sender: TObject); Begin WriteLn('event triggered'); WriteLn(sender.ClassName); end; var mTemp: TMyObject; mTemp := TMyObject.Create; mTemp.Trigger; mTemp.OnClick := HandleEvent; // <--Throws compiler error "More arguments expected" mTemp.Trigger; {<<< RESULT - CONSOLE LOG >>> ----------------------------- Errors >>>> Hint: "onClick" does not match case of declaration ("OnClick") [line: 33, column: 7] Result >>>> event triggered TMyObject ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}