#include #include #include void exec3() { // Example of using signal/slot in TCanvas/TPad to get feedback // about mouse-click events. //Author: Ilka Antcheva TCanvas *c1=new TCanvas("c1"); TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); hpxpy->SetStats(0); Double_t px,py; for (Int_t i = 0; i < 50000; i++) { gRandom->Rannor(px,py); hpxpy->Fill(px,py); } hpxpy->Draw("col"); c1->Update(); c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0, "exec3event(Int_t,Int_t,Int_t,TObject*)"); } void exec3event(Int_t event, Int_t x, Int_t y, TObject *selected) { TCanvas *c = (TCanvas *) gTQSender; if (event == kButton1Down) // mouse click printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n", c->GetName(), event, x, y, selected->IsA()->GetName()); }