Hi,
I'd like to bump this old request, based on a different use case.
We use the
OnScroll
event to synchronize the (horizontal, i.e. date) position of our Gantt chart with a corresponding workload chart we display below it. When panning via mouse button this works by simply setting
Code: Select all
dbChartLoad.BottomAxis.SetMinMax(dbChartGantt.TopAxis.Minimum,
dbChartGantt.TopAxis.Maximum);
or vice versa in the
OnScroll
event handler.
Since one of our recent updates (probably the Bug #2433 fix for horizontal-only mouse wheel scrolling), the charts now react to the mouse wheel - which is good - but they don't sync.
Our somewhat dirty workaround is propagating the actual scrolling by calling the other chart's corresponding protected function from the mouse wheel event handler:
Code: Select all
type
TkoDBChartAccessor = class(TDBChart);
var
fSyncMouseWheelTarget : TDBChart;
procedure TSomeFrame.dbChartGanttOrLoadMouseWheel(Sender: TObject;
Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint; var Handled: Boolean);
begin
if Sender = fSyncMouseWheelTarget then
begin
//end recursion: don't propagate any further, but don't prevent the
//scrolling either
exit;
end;
if Sender = dbChartGantt then
begin
fSyncMouseWheelTarget := dbChartLoad;
end
else //Sender = dbChartLoad
begin
fSyncMouseWheelTarget := dbChartGantt;
end;
try
TkoDBChartAccessor(fSyncMouseWheelTarget).DoMouseWheel(Shift, WheelDelta,
MousePos);
finally
fSyncMouseWheelTarget := nil;
end;
end;
I also tried adding a
TChartScrollBar
but it did not trigger the
OnScroll
event either. Since I ran into some other trouble with it also, we postponed that. In any case, supporting the OnScroll-Event no matter the scrolling method would provide for a straightforward and clean solution.
Our current build version is 2023.37.230130.
Thanks in advance for checking again,
Stefan