Recent

Author Topic: getting x y coords from TChart onMouseMove  (Read 12411 times)

acp693

  • Jr. Member
  • **
  • Posts: 59
getting x y coords from TChart onMouseMove
« on: July 03, 2009, 12:25:35 pm »
Hello,

After trying to use the OnMouseMove event of a TChart to display the X and Y coordinates in some TLabels, I discovered that the TChart OnMouseMove event is overridden in the Unit TAGraph. In Unit TAGraph I added the following line in the OnMouseMove procedure:

Unit1.Form1.Label1.Caption:= IntToStr(X)+ '  ' +IntToStr(Y);

I then added Unit1 to the uses in the Interface section of TAGraph. However compilation fails with the following message: tagraph.pas(39,1) Fatal: Can't find unit Unit1 used by TAGraph. Presumably this is because TAGraph resides in a different folder than the project?

Any Ideas How I make Unit1 visible to TAGraph?

Thanks

Albert

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: getting x y coords from TChart onMouseMove
« Reply #1 on: July 03, 2009, 01:45:01 pm »
You cannot do that. Packages are compiled seperated from the main program and files from a project can depend (=use) on files in a package, but not the other way around.


acp693

  • Jr. Member
  • **
  • Posts: 59
Re: getting x y coords from TChart onMouseMove
« Reply #2 on: July 03, 2009, 02:20:43 pm »
Thanks Vincent, So how can I get the x y coords from the mouse movement if the OnMouseMove event is overridden on a Tchart object and I can't pass objects from my Form, to the TAGraph Unit where the OnMouseMove event is implemented?

Regards

Albert

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
Re: getting x y coords from TChart onMouseMove
« Reply #3 on: July 03, 2009, 06:07:42 pm »
Components should never use these events for their own use, but override the virtual MouseMove methind. What do you mean by an overridden OnMouseMove ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

acp693

  • Jr. Member
  • **
  • Posts: 59
Re: getting x y coords from TChart onMouseMove
« Reply #4 on: July 03, 2009, 06:40:24 pm »
Hello Marc, On line 262 of Unit TAGraph under protected, is the line:

procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; 

If I remove the override statement then x and y become available in the OnmouseMove event for my tchart (chart1) in my unit, However then the tchart Zoom functions etc. don't work anymore. I just assumed that override means override the OnMouseMove event of my chart1 component. I've most likely misunderstood something here. Any ideas?

Regards

Albert

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: getting x y coords from TChart onMouseMove
« Reply #5 on: July 03, 2009, 08:59:36 pm »
I think there is a bug in TChart.MouseMove, that it does not call inherited always. Other TChart mouse method seem to be affected too.

Please create a bug report.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
Re: getting x y coords from TChart onMouseMove
« Reply #6 on: July 04, 2009, 01:23:40 am »
OK, I would call this a bug of TAChart. Overriding MouseMove like it is done is the way to do it.
I don't know if the author had a reason for not passing x and y
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

acp693

  • Jr. Member
  • **
  • Posts: 59
Re: getting x y coords from TChart onMouseMove
« Reply #7 on: July 10, 2009, 12:35:01 pm »
Hi, I posted a bug report. I notice that the bug is scheduled to be resolved for Target Version =>1.0.0 , Does this mean Lazarus version 1.0.0?  As it took two years to get from version 0.9.22 to 0.9.26.2 ,it might take a long time to get resolved? I realise that this is a very minor bug and probably effects very very few people, but I can't procede with my application without this, as I need to interact with the charts using the mouse. Is there some kind of workaround?

I would willingly help in trying to resolve this, but as a complete oop newbie, I'm very much out of my depth.  :(

Best regards and thanks for a truly great program, I voted for it in the community choice awards.

Albert

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: getting x y coords from TChart onMouseMove
« Reply #8 on: July 10, 2009, 01:06:51 pm »
If you want it to resolved before, supply a patch, then we add it in the next release or the one after that, if the next release in imminent.