In addition to Rene's exec3.C you also have the choice to use
signal/slots for this, see exec4.C:
void exec4() {
TH1F *h = new TH1F("h","h",100,-3,3);
h->FillRandom("gaus",1000);
TCanvas *c1=new TCanvas("c1");
h->Draw();
c1->Update();
c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, "",
"exec4event(Int_t,Int_t,Int_t,TObject*)");
}
void exec4event(Int_t event, Int_t x, Int_t y, TObject *selected)
{
TCanvas *c = (TCanvas *) gTQSender;
printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n",
c->GetName(), event, x, y, selected->IsA()->GetName());
}
An advantage here is that the slot function can be a method of your
class that has access to all the class data members. For more see:
http://root.cern.ch/root/HowtoSignalSlot.html
Cheers, Fons.
On Thu, 2002-07-18 at 21:41, Ed Oltman wrote:
> Hello,
>
> Is there a way to determine if the mouse is positioned within a canvas and
> the left button is pressed? TCanvas::GetSelected() returns a pointer to the
> selected TObject, in the canvas, but I would also like to know if the left
> button is pressed. I cannot sense the button state from within at TExec. I
> am using Root 3.02/07 on Win32. Thanks..
>
> Ed
>
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET