Page 1 of 1

Annotation mouse click fires chart mouse click FIRST

Posted: Mon Sep 21, 2009 1:50 am
by 10548832
I have a problem with TAnnotations. I create them on the fly and place them on a chart and give them a click property.

With MyAnnotation do
OnClick := AnnotationClick;

procedure Chart1.AnnotationClick(Sender: TAnnotationTool; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
If (Button = mbRight) then ...

All went well when mouse clicking on the annotation. I captured the right mouse button and did further processing.

However, I have now given the chart a mousedown event capturing the right mouse button for further processing.

Now when clicking on the annotation, the charts mouse click fires first. Not the annotations mouse click. The annotation click fires second. Have you any idea how I may get around this? How can I recognise the annotation has been clicked and so get the charts mouse click to disregard further processing?

Re: Annotation mouse click fires chart mouse click FIRST

Posted: Mon Sep 21, 2009 11:38 am
by yeray
Hi Phineas,

You can use the Annotation.Clicked function to see if the OnMouseDown event has been fired over the annotation or not. For example:

Code: Select all

procedure TForm1.MouseDown(Sender:TObject; Button:TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Annotation.Clicked(X,Y) then
    ShowMessage('annotation clicked!')
  else
    ShowMessage('mouse down!');
end;