Remove(or block) some items of the TCanvas' contextmenu?

Dear you,

I want to remove (or block) some items (such as the ‘SetEditable’) from the TCanvas’ contextmenu. Is there a way to do this?

Any help is appreciated.


Hi Handong,

Take a look at $ROOTSYS/tutorials/gui/customTH1Fmenu.C and at this simple example:

[code]void removeMenuEntry(const char *classname=“TCanvas”, const char *menuTitle=“SetEditable”)
TClassMenuItem *item;
TString itemTitle;
TClass *cl = gROOT->GetClass(“TCanvas”);

TList *ml = cl->GetMenuList();
TIter next(ml);
while ((item =(TClassMenuItem *)next())) {
itemTitle = item->GetTitle();
if (itemTitle == menuTitle) {
delete item;
Cheers, Bertrand.

Dear Bertrand,

Thank you very much!
It works.

Best Regards,

Dear Handong,

You’re welcome! And glad to see you solved your problem :slight_smile:

Cheers, Bertrand.