Page 1 of 1

OnEnter and OnExit events dont work

Posted: Wed Nov 15, 2006 1:41 am
by 9241686
I am using Cbuilder6 with TChartPro 7.07

With the TChart, i need to use the OnExit event to hide some popup text when the mouse moves off the chart. (I have multiple Area series on the chart)

The OnExit and also the OnEnter events never get activated

This is easy to reproduce, just create these events and set a break point using the bebugger in the OnEnter or OnExit events

This not a biggie, just want the app to look a bit cleaner

Posted: Wed Nov 15, 2006 10:11 am
by narcis
Hi Bugsie,

Yes, this is a known issue(TV52011492) with a high-priority on our defect list to be fixed for future releases.

In the meantime you can simulate those events doing something like this:

Code: Select all

void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,
	  int Y)
{
	if (MouseOnChart)
	{
		MouseOnForm=true;
		MouseOnChart=false;
		Chart1->Title->Text->Clear();
		Chart1->Title->Text->Add("Exit Chart");
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Chart1MouseMove(TObject *Sender, TShiftState Shift,
	  int X, int Y)
{
	if (MouseOnForm)
	{
		MouseOnChart=true;
		MouseOnForm=false;
		Chart1->Title->Text->Clear();
		Chart1->Title->Text->Add("Enter Chart");
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
	MouseOnChart=false;
	MouseOnForm=true;
}

Posted: Wed Nov 15, 2006 10:16 am
by 9333771
hi,

OnExit and OnEnter are related with the FOCUS not the mouse position.
(this is valid for all the delphi's vcl, try with a TPanel)

I did have a similar problem, I did use the OnMouseMove of the Form and test the position of the mouse ( PtInRect or by hand). This is not perfect but it works.

Posted: Fri Nov 17, 2006 1:04 pm
by narcis
Hello everyone,

Sorry for the confusion, Mariano is right. For those events to work the chart needs the focus. When it has the focus then all OnKeyxxxx events also work:

Code: Select all

procedure TForm1.Chart1Enter(Sender: TObject); begin
  Color:=clWhite;
end;

procedure TForm1.Chart1Exit(Sender: TObject); begin
  Color:=clBtnFace;
end;

procedure TForm1.Button1Click(Sender: TObject); begin
  Chart1.SetFocus;
end;

procedure TForm1.Chart1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Caption:=IntToStr(Key);
end;
Regarding Bugsie's request, we could add OnMouseEnter and OnMouseExits events.