Page 1 of 1

Panning and pop-up menus

Posted: Thu Jun 18, 2015 11:14 am
by 16569987
Hi,

With the conventional use of a pop-up menu on the right mouse click event, I can't use the TChart's automatic panning on the right mouse button, not even if I require e.g. [ssCtrl] in the TeeScrollKeyShift property.

I can't run the pan function on the left mouse button without losing the automatic zoom, again, even using TeeScrollKeyShift.

Is it possible to run the pan function through some other combination of keys so that the user does not have to explicitly switch between zoom and pan modes?

Thanks for any advice!

Toreba

Re: Panning and pop-up menus

Posted: Thu Jun 18, 2015 3:00 pm
by yeray
Hello toreba,

This seems to do the trick:

Code: Select all

var DownPos: TPoint;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  DownPos.X:=X;
  DownPos.Y:=Y;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button=mbRight) and (DownPos.X = X) and (DownPos.Y = Y) then
    PopupMenu1.Popup(GetClientOrigin.X+Chart1.Left+X, GetClientOrigin.Y+Chart1.Top+Y);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  PopupMenu1.AutoPopup := false;
  Chart1.PopupMenu := PopupMenu1;
end;

Re: Panning and pop-up menus

Posted: Fri Jun 19, 2015 2:52 pm
by 16569987
Yeray,

Yeah, that's neat! Thanks very much!

Regards

Toreba