Page 1 of 1

Strange scrolling behaviour using mouse wheel

Posted: Thu Jul 24, 2014 6:11 am
by 16567585
In the TTree component of TeeChart 2014 of May, 12, 2014, one can observe a strange scrolling behviour using the mouse wheel.
At first, the tree is scrolled beyond the top and the bottom if the top or bottom of the tree is reached.
Second, the zooming direction is inverted in contrast to the TTree component of TeeChart 2012.
Therefore, I changed TeeTree.pas, function TCustomTree.InternalWheel, in the following way:

Code: Select all

procedure TCustomTree.InternalWheel(IsDown:Boolean);
var tmp : Double;
    tmpFactor : Integer;
begin
  if IsDown then
     tmpFactor:=+1
  else
     tmpFactor:=-1;

  case FWheelNavigation of
    wnSelection     : if IsDown then
                         ProcessKey(TeeTree_DownKey,[]) // navigate one node down
                      else
                         ProcessKey(TeeTree_UpKey,[]);  // navigate one node up

    wnScrollVert    : with View3DOptions do
                        //   VertOffset:=VertOffset+tmpFactor*TreePageScrollQuantity;
                        // Avoid scrolling beyond top and bottom
                        if VertScrollBar.Visible then
                        begin
                           if IsDown then
                             VertOffset:=Max(VertOffset-tmpFactor*TreePageScrollQuantity, -(VertScrollBar.Max - VertScrollBar.PageSize + 1))
                           else
                             VertOffset:=Min(VertOffset-tmpFactor*TreePageScrollQuantity, 0);
                        end;

    wnScrollHoriz   : with View3DOptions do
                           HorizOffset:=HorizOffset+tmpFactor*2;

    wnZoom          : with View3DOptions do
                      begin
                        tmp:=Math.Max(1,0.05*ZoomFloat);
                     // Ensure zooming behaviour of TeeChart 2012:
                     // to top downsize, to bottom enlarge
                     // ZoomFloat:=Max(1,ZoomFloat-tmpFactor*tmp);
                        ZoomFloat:=Max(1,ZoomFloat+tmpFactor*tmp);
                      end;
  end;
end;

Re: Strange scrolling behaviour using mouse wheel

Posted: Tue Aug 05, 2014 9:34 am
by yeray
Hello,

I've placed a TTree and a TChart in a form and wrote this simple code:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Tree1.WheelNavigation:=wnZoom;

  Chart1.Panning.MouseWheel:=pmwNone;
  Chart1.ZoomWheel:=pmwNormal;

  Chart1.AddSeries(TBarSeries).FillSampleValues();
  Tree1.AddRoot('First node').AddChild('First child');
  Tree1.Shape[0].Expanded:=true;
end;
If I focus the chart, mouseUp zooms in, and mouseDown zooms out.
If I focus the tree, mouseUp zooms in, and mouseDown zooms out.

So I don't see the problem you describe. Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.

Re: Strange scrolling behaviour using mouse wheel

Posted: Sun Aug 17, 2014 8:36 am
by 16567585
Sorry, I forgot to tell you some details.
Put a TTree on a form, add three buttons and fill the form's OnCreate and the buttons' OnClick event handlers with the following code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  Tree1.WheelNavigation := wnScrollVert;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Tree1.WheelNavigation := wnZoom;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Tree1.WheelNavigation := wnSelection;
end;

procedure TForm1.FormCreate(Sender: TObject);

  procedure Local_InitNode(pxNode : TTreeNodeShape);
  begin
    pxNode.Border.Visible := False;
    pxNode.ImageIndex := tiNone;
  end;

var
  liI    : Integer;
  lxRoot,
  lxNode : TTreeNodeShape;
begin
  Button1.Caption := 'wnScrollVert';
  Button2.Caption := 'wnZoom';
  Button3.Caption := 'wnSelection';

  Tree1.Canvas := TTeeCanvas3D.Create;
  lxRoot := Tree1.AddRoot('Root');
  Local_InitNode(lxRoot);
  for liI := 0 to 100 do
  begin
    lxNode := lxRoot.AddChild(IntToStr(liI+1));
    Local_InitNode(lxNode);
  end;

  lxRoot.Expanded := True;
end;
Then, execute, click the wnScrollVert button and use the mouse wheel for scrolling. You'll see that the tree moves out of view if the top or bottom is reached.
Afterwards, click the wnZoom button and use the mouse wheel for zooming. You will recognize that zooming in and zooming out is interchanged when compared with TeeTree of TeeChart 2012.
The code that I provided in my original post fixes the problem.

Re: Strange scrolling behaviour using mouse wheel

Posted: Mon Aug 18, 2014 12:45 pm
by yeray
Hello,

I see the directions of both wnScrollVert and wnZoom changed from v2013.08.
- In v2013.07, with wnScrollVert, MouseWheelUp displaces the Tree view up (the text moves down) while MouseWheelDown displaces the view down (the text moves up). And with wnZoom, MouseWheelUp zooms the three out while MouseWheelDown zooms the three in.

- In v2013.08 and up, with wnScrollVert, MouseWheelUp displaces the Tree view down (the text moves up) while MouseWheelDown displaces the view up (the text moves down). And with wnZoom, MouseWheelUp zooms the three in while MouseWheelDown zooms the three out.

Also, from v2013.09 you can use the MouseWheel to scroll & zoom a TChart.
- In v2013.09 and up, with Panning.MouseWheel=pmwNormal, MouseWheelUp displaces the Chart view up (the series move down) while MouseWheelDown displaces the view down (the series move up). And with Panning.MouseWheel=pmwNone and ZoomWheel=pmwNormal, MouseWheelUp zooms the chart in while MouseWheelDown zooms the chart out.

I agree we should revise this, so I've opened a ticket in the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=889
TreeScrollVsZoom.zip
(1.04 MiB) Downloaded 2702 times