Context menu active area

Hi,

Is there a way to define the area in the pad where right clicking will activate given object’s context menu? Alternatively, is there a way to add a menu to the TCanvas menu bar?

The reason for this question is somewhat convoluted. I have a class which builds a lightcurve (plot of flux versus time for the non-astronomers) and inherits from TH1D. It uses this inheritance to take advantage of useful functions of TH1D (such as the ability to deal with binning) while calculating internal values. However the calculations are done in a particular set of units (namely number of photons, and seconds), whereas I need the user to be able to draw the class in terms of other units (e.g. TeV and days) which can be selected from a context menu. I accomplish this by converting the internally stored histogram values into two TGraphs (one for real flux points and one for upper limits) which I then transform into the appropriate units (using TGraph::Apply()), and then draw into the pad. The problem is that on drawing, I use none of the graphical primitives associated with the lightcurve class which is being drawn (the axes belong to the TGraph as they must because they are now in different units to the class’s axes), so there is no way to access context menus of the lightcurve class from the Pad.

I realise that this may well be an issue with poor design on my part, but implementing the class this way simplifies the problem in all respects but menu access! I’m willing to consider other approaches, as long as I don’t have to start again from scratch!

Another problem may be that I’m not 100% clear on the difference between the Paint() and Draw() methods. Should my class override both, and what functions should each perform?

Cheers,

Hugh

This (the difference between Paint and Draw) is explained here:
root.cern.ch/drupal/content/graphics-pad

So what exactly defines which primitives in the pad constitute the clickable area for a given class. Is it those objects painted by the Paint() method of that class?

In each clickable class this is define by the method DistancetoPrimitive(). Then when a primitive is picked the action to perfom on it are done by ExecuteEvent().

see : root.cern.ch/drupal/content/how-pick-objects

Rene

Thanks for the quick replies. It’s working great now!

Cheers,

Hugh