Hello Rooters,
I have written a small macro using the signal/slot machanism (See below). Using the Signal KeyPressed(int) from gApplication I was able to go through an opened root-file and see all the histograms with the ‘+’ and the ‘-’ Keys.
Now the question:
How do I prevent the ‘+’ or the ‘-’ Charakter to be printed in the Console? Is there something like “if key is + don’t plot charakter on console”?
Thank you
Lutz
///////////toggle macro///////////////////////////////
void execEvent(Int_t keyb)
{
static int keynum;
if (!gDirectory->GetNkeys()) return;
if (keyb ==45) //minus
{
if (keynum > 0) --keynum;
}
else if (keyb==43) //plus
{
if (gDirectory->GetNkeys()-1 > keynum) ++keynum;
}
else if (keyb==115) // key 's'
{
cout<<"exiting"<<endl;
gApplication->Disconnect();
return;
}
else
{
return;
}
TCanvas *c0 = gPad->GetCanvas();
TKey *key = gDirectory->GetListOfKeys()->At(keynum);
TObject *obj = key->ReadObj();
if ( obj->IsA()->InheritsFrom( "TH1" ) )
{
TH1 *h1 = (TH1*)obj;
h1->Draw();
c0->Modified();
c0->Update();
}
delete obj;
}
void toggle()
{
gApplication->Connect("KeyPressed(Int_t)",0,0,"execEvent(Int_t)");
}