Hello,
is there a way to use Events in a script? It was fired once at start but wen the Class should do.
Delphi:
type
TmgmGefallKopierenModel = class;
TmgmGfKopierNotifyEvent = procedure(Sender: TmgmGefallKopierenModel) of object;
TmgmGefallKopierenModel = class(TComponent)
private
FOnAfterCopyPosition: TmgmGfKopierNotifyEvent;
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure DoSomething;
published
property OnAfterCopyPosition: TmgmGfKopierNotifyEvent read FOnAfterCopyPosition write FOnAfterCopyPosition;
end;
Script:
procedure OnAfterGfCopyPositionX(Sender: TmgmGefallKopierenModel);
begin
ShowMessage('OnAfterGfCopyPositionX: ' );
end;
procedure UDO_Button_Click;
var
LoGfKopieren: TmgmGefallKopierenModel;
begin
LoGfKopieren := TmgmGefallKopierenModel.Create(CallForm);
LoGfKopieren.OnAfterCopyPosition := OnAfterGfCopyPositionX(LoGfKopieren);//-> The Event ist called;
LoGfKopieren.DoSomething; // here the Event isn't called.
wlandgraf
(Wagner Landgraf)
May 2, 2021, 11:25pm
2
Yes, you can use events but:
Events in scripter are set using the method name as string. For example:
LoGfKopieren.OnAfterCopyPosition := 'OnAfterGfCopyPositionX';
You have to register the event type in advance so scripter know about it.
Some examples:
For some reason a customer who upgraded to our latest version is having an issue with an OnDrawCell event. They get the error: "TRzStringGrid: OnDrawCell Event adapter not defined." I see in the manual this:"the OnEvent handlers are not automatically defined by scripter. You must implement aTatEventDispatcher descendant class and use DefineEventAdapter method." But I couldn't find any information on how the DefineEventAdapter methods work in the docs. Here is how the procedure is defined:procedu…
Hello, use this: DefineEventAdapter(TypeInfo(TDrawColumnCellEvent), TMyDBGridsDispatcher, @TMyDBGridsDispatcher.__TDBGridDrawColumnCell);
type
TMyDBGridsDispatcher = class(TatEventDispatcher)
private
procedure __TDBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
end;
uses ap_Types
procedure TMyDBGridsDispatcher.__TDBGridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; St…
system
(system)
Closed
May 3, 2021, 11:24am
4
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.