Page 1 of 1

Trying to implement panning/scroling

Posted: Sun Jun 29, 2014 5:15 pm
by 17568804
Hi all.

As I want more control about panning, and as the default panning provided doesn't work well, I tried to implement panning myself using gestures in FireMonkey. Here is what I got so far for the X axis only:

Code: Select all

procedure TMultiEPGFrame.FrameGesture(Sender: TObject;
  const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
  lGlobalWidth: Double;
  lLocalWidth: Double;
begin
  if EventInfo.GestureID = igiPan then
  begin
    lGlobalWidth := self.Width;
    lLocalWidth := fChart.BottomAxis.Maximum - fChart.BottomAxis.Minimum;

    if fLastPosition.X < EventInfo.Location.X then
    begin
      fChart.BottomAxis.Minimum := fChart.BottomAxis.Minimum -
        ((EventInfo.Location.X) / lGlobalWidth);

      fChart.BottomAxis.Maximum := fChart.BottomAxis.Maximum -
        ((EventInfo.Location.X) / lGlobalWidth);
    end
    else
    begin
      fChart.BottomAxis.Minimum := fChart.BottomAxis.Minimum +
        ((EventInfo.Location.X) / lGlobalWidth);

      fChart.BottomAxis.Maximum := fChart.BottomAxis.Maximum +
        ((EventInfo.Location.X) / lGlobalWidth);
    end;

    fLastPosition := EventInfo.Location;
  end;
end;
I basically adjust the maximum and minimum of my X axis approximately by the amount my finger goes left or right ... If anyone has a better suggestion, I am all ears!

Thanks a lot!
CJ

Re: Trying to implement panning/scroling

Posted: Tue Jul 01, 2014 10:57 am
by yeray
Hi CJ,

This seems to be related to this thread.
As Pep said there, setting the Left button as the ScrollMouseButton should make the default scoll feature usable in mobile applications.

Re: Trying to implement panning/scroling

Posted: Tue Jul 01, 2014 5:58 pm
by 17568804
Yes, thanks this works - one more question though also asked in the other thread:

How do I block panning/scrolling to work inside some arbitrary bounds only?

Cheers,
CJ

Re: Trying to implement panning/scroling

Posted: Tue Jul 01, 2014 8:57 pm
by 17568804
This is a solution I implemented which works:
http://www.teechart.net/support/viewtop ... 661#p66661

Re: Trying to implement panning/scroling

Posted: Wed Jul 02, 2014 7:22 am
by yeray
Hi CJ,

We'll reply you in the other thread as soon as possible.
There's no need to maintain two threads with the same questions and answers.