Trying to implement panning/scroling

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
cjacoby78
Newbie
Newbie
Posts: 11
Joined: Tue Mar 25, 2014 12:00 am

Trying to implement panning/scroling

Post by cjacoby78 » Sun Jun 29, 2014 5:15 pm

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

Yeray
Site Admin
Site Admin
Posts: 8738
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to implement panning/scroling

Post by Yeray » Tue Jul 01, 2014 10:57 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

cjacoby78
Newbie
Newbie
Posts: 11
Joined: Tue Mar 25, 2014 12:00 am

Re: Trying to implement panning/scroling

Post by cjacoby78 » Tue Jul 01, 2014 5:58 pm

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

cjacoby78
Newbie
Newbie
Posts: 11
Joined: Tue Mar 25, 2014 12:00 am

Re: Trying to implement panning/scroling

Post by cjacoby78 » Tue Jul 01, 2014 8:57 pm

This is a solution I implemented which works:
http://www.teechart.net/support/viewtop ... 661#p66661

Yeray
Site Admin
Site Admin
Posts: 8738
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to implement panning/scroling

Post by Yeray » Wed Jul 02, 2014 7:22 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply