OnMouseDown event on TIWChart does not work
OnMouseDown event on TIWChart does not work
Hi,
I'm currently trying to use TeeChart in an Intraweb application. I am using Delphi XE, TeeChart 2012 and Intraweb XII.
My problem is that the OnMouseDown event of the TIWChart does not seem to occur when I click on the generated chart in my web browser. This is rather strange, since if I change the event to an OnClick event, then this DOES occur when I click on the chart in the web browser.
For reference, I have done the following:
- downloaded "TeeChart 2010 Standard for IntraWeb XI and Delphi XE" from http://www.steema.com/download/vcl
- changed "Tee" to "Tee915" and "IWExtCtrls" to "IWCompExtCtrls"
- built the packages and installed the TIWChart component
- created a new Intraweb application
- added a TChart and a TIWChart component to the design page, as well as a TIWLabel
- set the Chart property of the TIWChart to the name of the TChart
- added an OnMouseDown event to the TIWChart
Can you advise me what I need to do to get the OnMouseDown event of the TIWChart working? Alternatively, how can I find out where a user has clicked on the TIWChart?
Many thanks,
Stephen
I'm currently trying to use TeeChart in an Intraweb application. I am using Delphi XE, TeeChart 2012 and Intraweb XII.
My problem is that the OnMouseDown event of the TIWChart does not seem to occur when I click on the generated chart in my web browser. This is rather strange, since if I change the event to an OnClick event, then this DOES occur when I click on the chart in the web browser.
For reference, I have done the following:
- downloaded "TeeChart 2010 Standard for IntraWeb XI and Delphi XE" from http://www.steema.com/download/vcl
- changed "Tee" to "Tee915" and "IWExtCtrls" to "IWCompExtCtrls"
- built the packages and installed the TIWChart component
- created a new Intraweb application
- added a TChart and a TIWChart component to the design page, as well as a TIWLabel
- set the Chart property of the TIWChart to the name of the TChart
- added an OnMouseDown event to the TIWChart
Can you advise me what I need to do to get the OnMouseDown event of the TIWChart working? Alternatively, how can I find out where a user has clicked on the TIWChart?
Many thanks,
Stephen
Re: OnMouseDown event on TIWChart does not work
Hi Stephen,
We'll prepare an environment like yours and investigate it as soon as possible.
In the meanwhile, isn't the OnClick event offer an acceptable workaround for you?
We'll prepare an environment like yours and investigate it as soon as possible.
In the meanwhile, isn't the OnClick event offer an acceptable workaround for you?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: OnMouseDown event on TIWChart does not work
Hi Yeray,
The problem I have with the OnClick event is that it does not give me the position of the cursor when it is clicked.
I am trying to identify where the user has clicked in the plot. How should I do this via the OnClick event?
Many thanks,
Stephen
The problem I have with the OnClick event is that it does not give me the position of the cursor when it is clicked.
I am trying to identify where the user has clicked in the plot. How should I do this via the OnClick event?
Many thanks,
Stephen
Re: OnMouseDown event on TIWChart does not work
Hi Stephen,
Right, the OnClick event doesn't give you the mouse position. However, this event is fired later than the OnMouseDown/OnMouseMove events, events that give you the mouse coordinates. So you could save the current mouse position in global variables with one of these events and use that variable at OnClick event.
Don't hesitate to let us know if you still find problems with it.
Ah, I understood the event wasn't fired at all!Stephen wrote:The problem I have with the OnClick event is that it does not give me the position of the cursor when it is clicked.
I am trying to identify where the user has clicked in the plot. How should I do this via the OnClick event?
Right, the OnClick event doesn't give you the mouse position. However, this event is fired later than the OnMouseDown/OnMouseMove events, events that give you the mouse coordinates. So you could save the current mouse position in global variables with one of these events and use that variable at OnClick event.
Don't hesitate to let us know if you still find problems with it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: OnMouseDown event on TIWChart does not work
Yeray,
You are correct in understanding that the OnMouseDown event DOES NOT fire at all. That means that I still have the same problem of not being able to recover the mouse coordinates on click or mouse down.
Stephen
You are correct in understanding that the OnMouseDown event DOES NOT fire at all. That means that I still have the same problem of not being able to recover the mouse coordinates on click or mouse down.
Stephen
Re: OnMouseDown event on TIWChart does not work
Hi Stephen,
You are right. However, I've observed you can get the mouse position with:
You are right. However, I've observed you can get the mouse position with:
Code: Select all
Mouse.CursorPos.X
Mouse.CursorPos.Y
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: OnMouseDown event on TIWChart does not work
Hi Yeray,
Thank you for your response.
Mouse.CursorPos.X and Mouse.CursorPos.Y give me absolute screen coordinates.
To convert these absolute screen coordinates into local coordinates relative to the TChart axes, I need to know where the TChart axes are plotted. I can see that TChart.ChartRect will give me the coordinates within the TIWChart region, and TIWChart.BoundsRect will give me the coordinates within the browser window. I see no obvious way to get the position of the browser window relative to screen coordinates without installing the components from http://code.google.com/p/iwopensource/.
Am I missing something? Is there some easier way to get the local coordinates relative to the TChart axes?
Stephen
Thank you for your response.
Mouse.CursorPos.X and Mouse.CursorPos.Y give me absolute screen coordinates.
To convert these absolute screen coordinates into local coordinates relative to the TChart axes, I need to know where the TChart axes are plotted. I can see that TChart.ChartRect will give me the coordinates within the TIWChart region, and TIWChart.BoundsRect will give me the coordinates within the browser window. I see no obvious way to get the position of the browser window relative to screen coordinates without installing the components from http://code.google.com/p/iwopensource/.
Am I missing something? Is there some easier way to get the local coordinates relative to the TChart axes?
Stephen
Re: OnMouseDown event on TIWChart does not work
Hi Stephen,
I'm afraid TeeChart doesn't know the browser position to calculate the chart position relative to it, and substract that from the absolute mouse coordinates.
Maybe Atozed guys know a way to get the mouse coordinates relative to the browser or how to calculate them.
I'm afraid TeeChart doesn't know the browser position to calculate the chart position relative to it, and substract that from the absolute mouse coordinates.
Maybe Atozed guys know a way to get the mouse coordinates relative to the browser or how to calculate them.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: OnMouseDown event on TIWChart does not work
OK, I've found a workaround. Now, I work directly with the TIWImage component.
After adding the TIWImage component (called imgIWChart) and a TChart component (called chtOriginal), I use the following function to render the TChart in the TIWImage:
procedure TIWForm1.RedrawGraph;
var
lMF : TMetafile;
lBitmap : TBitmap;
lRect : TRect;
begin
// set the image dimensions of imgIWChart
lBitmap := imgIWChart.Picture.Bitmap;
lBitmap.Width := chtOriginal.Width;
lBitmap.Height := chtOriginal.Height;
imgIWChart.Width := chtOriginal.Width;
imgIWChart.Height := chtOriginal.Height;
// set the drawing rectangle for the TChart
lRect.Left := 0;
lRect.Top := 0;
lRect.Right := chtOriginal.Width;
lRect.Bottom := chtOriginal.Height;
try
// create an image metafile from the TChart
lMF := chtOriginal.TeeCreateMetafile(False, lRect);
// draw the metafile into the bitmap
lBitmap.Canvas.Draw(0, 0, lMF);
finally
FreeAndNil(lMF);
end;
end;
Then, I use the OnAsyncMouseDown event for the TIWImage to give me the local coordinates within the TIWImage component, and map these into local TChart coordinates via TChart.ChartRect.
Stephen
After adding the TIWImage component (called imgIWChart) and a TChart component (called chtOriginal), I use the following function to render the TChart in the TIWImage:
procedure TIWForm1.RedrawGraph;
var
lMF : TMetafile;
lBitmap : TBitmap;
lRect : TRect;
begin
// set the image dimensions of imgIWChart
lBitmap := imgIWChart.Picture.Bitmap;
lBitmap.Width := chtOriginal.Width;
lBitmap.Height := chtOriginal.Height;
imgIWChart.Width := chtOriginal.Width;
imgIWChart.Height := chtOriginal.Height;
// set the drawing rectangle for the TChart
lRect.Left := 0;
lRect.Top := 0;
lRect.Right := chtOriginal.Width;
lRect.Bottom := chtOriginal.Height;
try
// create an image metafile from the TChart
lMF := chtOriginal.TeeCreateMetafile(False, lRect);
// draw the metafile into the bitmap
lBitmap.Canvas.Draw(0, 0, lMF);
finally
FreeAndNil(lMF);
end;
end;
Then, I use the OnAsyncMouseDown event for the TIWImage to give me the local coordinates within the TIWImage component, and map these into local TChart coordinates via TChart.ChartRect.
Stephen
Re: OnMouseDown event on TIWChart does not work
Hi Stephen,
Great! Thanks for sharing!
Great! Thanks for sharing!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |