Page 1 of 1

TeeUseMouseWheel and OnAllowScroll problem

Posted: Fri Jul 27, 2007 12:44 pm
by 9047589
The problem is that scrolling with MouseWheell doesn't fire OnAllowScroll event thus preventing me from control of moving all series outside ChartRect.

Posted: Fri Jul 27, 2007 4:04 pm
by Pep
Hi Alexander,

yes, since we add this checking on our sources (which is on our wish list) it will have to be done manually.
You could use the OnAfterDraw event to do it, using similar code to the following one :

Code: Select all

procedure TForm1.Chart1AllowScroll(Sender: TChartAxis; var AMin,
  AMax: Double; var AllowScroll: Boolean);
begin
 // your code here...
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var axisleftmin,axisleftmax : double;
    scroll : boolean;
begin
  axisleftmin := Chart1.axes.left.minimum;
  axisleftmax := Chart1.axes.left.maximum;
  scroll := true;

if TeeUseMouseWheel=true then
  Chart1AllowScroll(chart1.Axes.Left,axisleftmin,axisleftmax,scroll);
end;

Posted: Fri Jul 27, 2007 5:07 pm
by 9047589
Seems you meant in a such way?

Code: Select all

if TeeUseMouseWheel=true then 
begin
  Chart1AllowScroll(chart1.Axes.Left,axisleftmin,axisleftmax,scroll); 
  if scroll then
    chart1.Axes.Left.SetMinMax(axisleftmin,axisleftmax)
  else
    ???  
end; 
Unfortunately, at the point, marked with questions, previous minimum and maximum of an axis are already lost and refusing scroll is not possible:cry:
Have a good weekend!

Posted: Mon Jul 30, 2007 4:26 pm
by Pep
Hi Alexander,

hmmm... how about ?

Code: Select all

  private
    min, max : double;

procedure TForm1.Chart1AllowScroll(Sender: TChartAxis; var AMin,
  AMax: Double; var AllowScroll: Boolean);
begin
  if (Chart1.AllowPanning = pmVertical) or (Chart1.AllowPanning = pmBoth) then
    if (Amin<=min) or (Amax >= Max) then
        AllowScroll := false;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var axisleftmin,axisleftmax : double;
    axisleftmin2,axisleftmax2 : double;
    scroll : boolean;
begin
if assigned(Series1) then
begin
  if min = -1 then
   min := Chart1.Axes.Left.Minimum;

  if max = -1 then
    max := Chart1.Axes.Left.Maximum;

  if TeeUseMouseWheel=true then
  begin
    axisleftmin := Chart1.axes.left.minimum;
    axisleftmax := Chart1.axes.left.maximum;
    Chart1AllowScroll(chart1.Axes.Left,axisleftmin,axisleftmax,scroll);
    if scroll then
    begin
      min := axisleftmin;
      max := axisleftmax;
    end
    else begin
     Chart1.Axes.Left.SetMinMax(min,max);
    end;
  end;
end;
end;

Posted: Mon Jul 30, 2007 6:43 pm
by 9047589
Thank you, Pep for this suggestion!
By this moment I undertook more radical workaround - completely intercepted default TeeChart scroll behavior in OnMouseWheel event.

Posted: Wed Aug 01, 2007 1:08 pm
by 9047589
By the way, scrolling with mouse seems ignores AllowPanning value :(

Posted: Wed Aug 01, 2007 2:03 pm
by narcis
Hi Alexander,

What about using TabStop property as suggested on this thread?

Thanks in advance.

Posted: Wed Aug 01, 2007 2:12 pm
by 9047589
Hi, Narchs!
It's not a problem for me to enable scroll, the issue is how to handle it in a uniform way with trapping OnAllowScroll event and in accordance with AllowPanning value.
For better understanding let me bring up just an example - for some reasons I prevent a user from dragging series with Right Mouse by AllowPanning=pmHorizontal, however it (politely to say - he or she) is still able to shift series in vertical using MouseWheel.
For my projects I have already found a workaround, but in general I suggest this behavior must be changed.

Posted: Wed Aug 01, 2007 2:45 pm
by narcis
Hi Alexander,

Ok, as Pep said, this is already listed on our wish-list to be implemented for next releases.

Posted: Wed Aug 01, 2007 3:02 pm
by 9047589
narcis wrote: Ok, as Pep said, this is already listed on our wish-list to be implemented for next releases.
That's true, but because we discussed with him OnAllowScroll event I just added to the discussion AllowPanning issue. If it's also included into your wish list I'm almost (until next release:) satisfied.

Posted: Tue Aug 07, 2007 11:59 am
by Pep
Hi Alexander,
By the way, scrolling with mouse seems ignores AllowPanning value
Thanks for the advise. Yes, it's on our wish list too.