Recent

Author Topic: [Solved] ZoomDragTool problem with .IsZoomed  (Read 1830 times)

Muso

  • Full Member
  • ***
  • Posts: 209
[Solved] ZoomDragTool problem with .IsZoomed
« on: July 21, 2021, 09:16:35 pm »
I use in a chart the ZoomDragTool with the Shift state ssLeft.

I need to know when the user used it to zoom in. Therefore I added for the procedure OnAfterMouseUp a procedure. There I check .IsZoomed e.g. like this:

Code: Pascal  [Select][+][-]
  1. if Chart.IsZoomed then
  2.  mustWait:= true
  3.  else
  4.   mustWait:= false;

The problem is now that when the user just left-click on a chart axis, the chart title or footer, Chart.IsZoomed returns TRUE. How can I avoid this? I thought a left-click on the chart title was no zooming action.
« Last Edit: July 22, 2021, 03:59:38 am by Muso »

Muso

  • Full Member
  • ***
  • Posts: 209
Re: ZoomDragTool problem with .IsZoomed
« Reply #1 on: July 21, 2021, 09:37:07 pm »
The problem is now that when the user just left-click on a chart axis, the chart title or footer, Chart.IsZoomed returns TRUE. How can I avoid this? I thought a left-click on the chart title was no zooming action.

I found now out that the bug only occurs when the chart has a LiveView and its ExtentY is set to "lveAuto". The other ExtentY deliver Chart.IsZoomed= FALSE.

Besides this, why does the ZoomDragTool fire at all when the user clicks on the chart title or axis? These elements are out of the data area so nothing can be zoomed there.

wp

  • Hero Member
  • *****
  • Posts: 8550
Re: ZoomDragTool problem with .IsZoomed
« Reply #2 on: July 21, 2021, 10:43:27 pm »
Please post a demo project so that I can see what you are doing - there are numerous ways to do things differently.

But I think that the LiveView which works on the LogicalExtent is always "zoomed". "Zoomed" means: the currently visible viewport is different from the "full" extent.

One possibility (without having tested it) is maybe to determine the currently used LogicalExtent of the Chart and compare it with the PrevLogicalExtent. When the LogicalExtent is "smaller" then the user has zoomed in.
« Last Edit: July 21, 2021, 10:48:49 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Muso

  • Full Member
  • ***
  • Posts: 209
Re: ZoomDragTool problem with .IsZoomed
« Reply #3 on: July 21, 2021, 11:53:01 pm »
But I think that the LiveView which works on the LogicalExtent is always "zoomed". "Zoomed" means: the currently visible viewport is different from the "full" extent.

Yes. I debugged further and the issue occurs whenever LiveView is active, no matter what its ExtentY setting is.
And it seems exactly as you say - the extent movement puts it to Zoomed state.

Quote
One possibility (without having tested it) is maybe to determine the currently used LogicalExtent of the Chart and compare it with the PrevLogicalExtent. When the LogicalExtent is "smaller" then the user has zoomed in.

Many thanks I will try this out. If I can't find a solution, I will make a small demo program and post it here.

Muso

  • Full Member
  • ***
  • Posts: 209
Re: ZoomDragTool problem with .IsZoomed
« Reply #4 on: July 22, 2021, 12:30:02 am »
While I was looking at the features of the ZoomDragTool, I found the property "AdjustSelection". The IDe does not give me any info and also looking it the TAChart docs, I could not find what exactly this property does. Could you maybe please add some info about it to the XML file of the IDE and/or the TAChart docs?

Muso

  • Full Member
  • ***
  • Posts: 209
Re: ZoomDragTool problem with .IsZoomed
« Reply #5 on: July 22, 2021, 03:59:23 am »
Quote
One possibility (without having tested it) is maybe to determine the currently used LogicalExtent of the Chart and compare it with the PrevLogicalExtent. When the LogicalExtent is "smaller" then the user has zoomed in.

Many thanks I will try this out.

This works fine and solves my problem so far.

 

TinyPortal © 2005-2018