Context menu

Hello,

I am writing an app based on ROOT to be used for data analysis. Currently, the app creates a TGCanvas having a TGListTree containing histograms as TGListTreeItems. I would like to open a context menu when the user right clicks on one of these histograms, with options such as plotting in a new pad, overlaying in the current pad, etc. Is this possible and, if so, how? My guess is that I should create a class deriving from TGListTreeItem, with the appropriate member functions labelled with the comment // MENU. Is this correct? If so, what else is required?

Thanks in advance for any hints/advise/suggestions.

Joe Chuma
TRIUMF

Hi,
not for a moment … but we’re working on it :wink:
… root is not only but … :smiley: be done!

Regards. Valeriy

sorry.
Regards. Valeriy

Joe,

You do not need any special option to do what you want.
When you are in the browser or the canvas, click with the right button.
You get the object context menu. Select "DrawClone"
By default, this will draw the object in the current pad.
To select the current pad, simply click with the middle button
in the pad you want to set current.
When selecting the “DrawClone” item, you get a dialog box
where you can specify a “draw” option. eg “same” to overlay
on the current pad, etc

Rene

probably I’m buzzzing too much :unamused:

Hi,

Thank you Valeriy and Rene for your quick responses, but I think that Valeriy’s initial response (which has been removed) was what I was looking for. The confusion is my fault, as my question wasn’t clear. The context menus in the graphics window work fine. What I am trying to do is have a context menu open up with a right click on a TGListTreeItem in a non-graphics window. IIRC Valeriy said that this capability was not available, yet, but was in the works. In the time being, is there some work around? I can open a TGPopupMenu, but how do I find the position of the TGListTreeItem so the popup menu can be positioned close to the item on the monitor screen? Also, TGPopupMenu->AddEntry takes a string and an integer id as arguments, so how do I determine which menu item was chosen to call the proper call back function? I know I am asking a lot here, but any hints and/or suggestions would be welcome.

Thanks in advance,
Joe Chuma