Logo ROOT  
Reference Guide
customContextMenu.C File Reference

Detailed Description

Example showing how to add a function to the class context menu.

#include "TH1.h"
#include "TClassMenuItem.h"
#include "TList.h"
void poptest1(int a=5, int b = 56);
void poptest2(int a, int b, TObject* c);
void poptest2bis(TObject* c);
int poptest3();
void poptest4(char* ch);
void customContextMenu()
{
TH1F *h;
TH1F *h2;
TList *l;
// Create test histograms
h = new TH1F("h","Schtroumpf",100,-4,4);
h->FillRandom("gaus");
h->Draw();
h2 = new TH1F("h2","h2",1000,-4,4);
h2->FillRandom("gaus",30000);
// Retrieve menu list from TClass
TClass *cl = h->IsA();
l = cl->GetMenuList();
// Add some items to the popup menus
"Test object, draw a second h","Draw",h2,"Option_t*");
l->AddFirst(n);
l->AddFirst(n);
"test no 4","poptest4",0,"const char*");
l->AddFirst(n);
"test no 3","poptest3",0,"");
l->AddFirst(n);
"test no 2 bis","poptest2bis",0,"TObject*",2);
l->AddFirst(n);
"test no 2","poptest2",0,"int,int,TObject*",2);
l->AddFirst(n);
"test no 1","poptest1",0,"int,int");
l->AddFirst(n);
}
void poptest1(int a, int b)
{
printf("poptest1 %d %d\n",a,b);
}
void poptest2(int a, int b, TObject *c)
{
// Remark: the object c will not be asked for since it is the selected object
printf("poptest2 %d %d\n",a,b);
printf("histo : %lx\n",(Long_t)c);
printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
}
void poptest2bis(TObject *c)
{
// Remark: the object c will not be asked for since it is the selected object
printf("poptest2bis\n");
printf("histo : %lx\n",(Long_t)c);
printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
}
int poptest3()
{
printf("poptest3\n");
return 12;
}
void poptest4(const char *ch)
{
printf("poptest4 %s\n",ch);
}
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
#define h(i)
Definition: RSha256.hxx:106
long Long_t
Definition: RtypesCore.h:52
Describes one element of the context menu associated to a class The menu item may describe.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition: TClass.cxx:4304
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3445
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
const Int_t n
Definition: legend1.C:16
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12
Author
Ilka Antcheva

Definition in file customContextMenu.C.