Ok I have a function that returns to me a TMouseEvent type
I need to execute returned TMouseEvent but I dont know how.
Simple function returning an event:
function OMDold(obj: TObject): TMouseEvent
begin
... //some operations on obj
result := obj.OnMouseDown; //there is casting necessary, I skip it for simplify
end;
Currently the event is set to OMDnew which looks like:
procedure TfmAPRBasedForm.TSDragEvent(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if something then dosomething
else
begin
Sender.OnMouseDOwn := OMDold // OMDold in most cases returns null but its ok I just want to clear custom event from the object
//line below is a point of my question - the one I used doesnt work
TButton(Sender).OnMouseDown(Sender,Button,Shift,X,Y) //this line throws Access viloation at me
end;
end;
What I'm trying to achieve:
Geting button default OnMouseDown event and storing it in some record data
Changing ONMouseDown event to custom
During the custom event procedure there is a condition - if the mouse press was a drag, I execute drag code, if it wasn't I'd proceed with common click
To procced with common click I wanted to restore the default event and reeru it so the click could be executed
Thats it