How to dynamically change the label of a menu entry

Dear ROOT developers

I am wondering if there is an easy way to change the label of a menu entry dynamically. Let’s say I have an entry “Save”. Depending on the tab the user is in, I want it to read “Save X” or “Save Y”, just to give the user some information on what will happen… Therefore I am looking for a method TGMenuEntry::SetLabel(TGHotString* s), in analogy to GetLabel(). But there is no such thing. I can work around it by deleting the menu entry and adding it with a different label, but that seems rather clumsy (specially if you have to locate the separator before the entry…).

Perhaps this lack of functionality is on purpose, see I believe it would still be useful (better than deleting/adding).

Thanks for any suggestions!


Hi Thomas,

It is not possible right now. The problem is not only changing the text, but also hot keys bindings…
But I guess this could be added to our ToDo list…


Thanks for the information! I can manage with DeleteEntry/AddEntry. But I am really having trouble doing this when the entry is before a Separator. In TGPopupMenu::GetEntry(Int_t id) I read the following:

Could somebody perhaps provide a working example of this? How exactly do I “check the type” of the list item to extract the pointer to the separator such that I can give it to AddEntry() as the “before” argument?

Thanks again,


What about something like this:

TGMenuEntry *e; TIter next(Menu->GetListOfEntries()); while ((e = (TGMenuEntry*)next())) { if ( e->GetType() == kMenuSeparator ) { // Do whatever you want with it... [...] } } Cheers,

Yes, that’s exactly what I meant! It just didn’t occur to me. :blush:
Thank you so much,