Context Menu titles and "z-index" of drawn objects

Hello Rooters,

I have 2 questions related to the root code. Attached is a small script which demonstrates them both. The script defines a simple class inheriting from TEllipse and then draws 2 of them on a canvas.

The version of ROOT is 5.19/02 on linux. Verified with 5.14/00 on XP.

Question 1: related to z-indexes
Both of the circles have been set up in essentially identical ways, except the left one is colored white and the right one is colored red. Now, if you place the mouse pointer over the red circle, you will see that the status bar indicates that you are hovering over a MyE, the new class. However, if you hover over the white circle, you will see that you are hovering over the TFrame. You can verify this in either case by right-clicking to bring up the context menu.

From this I conclude that the z-index (to use CSS terminology) of the drawn objects depends on their color, which seems odd. Also, perhaps I missed this, but I could not find any way to adjust the z-index of objects apart from this. Being able to do this could be important to allow easy interaction with objects on the screen without having to select their edges, which can be tricky.

Question 2: related to context menus.
If you pull up the context menu on each of these circles, they show the same menu title “MyE”. It would be very useful to be able to have unique titles here based on the object name. Looking at
TContextMenu::CreatePopupTitle I think this is possible, but it isn’t clear from playing around how to properly name the object, or what class I need to inherit from to make this work. The context menu code takes the object name from the parent class (TObject) which defaults to using the class name as the object name. Any tips on how to do this?

Thanks for any comments

class MyE : public TEllipse { public: MyE(Double_t x1, Double_t y1, Double_t r1, int ID):TEllipse(x1, y1, r1){ fID = ID; } int fID; }; void test(){ TCanvas *c = new TCanvas("c","",400,400); c->DrawFrame(0,0,1,1); MyE *e1 = new MyE(0.25,0.5,0.25,333); MyE *e2 = new MyE(0.75,0.5,0.25,999); e1->SetFillColor(0); e2->SetFillColor(2); e1->Draw(); e2->Draw(); e1->IsA()->SetName("MyE"); }

[quote]Question 1: related to z-indexes
Both of the circles have been set up in essentially identical ways, except the left one is colored white and the right one is colored red. Now, if you place the mouse pointer over the red circle, you will see that the status bar indicates that you are hovering over a MyE, the new class. However, if you hover over the white circle, you will see that you are hovering over the TFrame. You can verify this in either case by right-clicking to bring up the context menu.

From this I conclude that the z-index (to use CSS terminology) of the drawn objects depends on their color, which seems odd. Also, perhaps I missed this, but I could not find any way to adjust the z-index of objects apart from this. Being able to do this could be important to allow easy interaction with objects on the screen without having to select their edges, which can be tricky.
[/quote]
By calling SetFillColor(0) you disable the fill area for the ellipse. Call SetFillColor(10) for example.
When the Fillarea is disabled the ellipse or circle can only be picked on the perimeter.

[quote]Question 2: related to context menus.
If you pull up the context menu on each of these circles, they show the same menu title “MyE”. It would be very useful to be able to have unique titles here based on the object name. Looking at
TContextMenu::CreatePopupTitle I think this is possible, but it isn’t clear from playing around how to properly name the object, or what class I need to inherit from to make this work. The context menu code takes the object name from the parent class (TObject) which defaults to using the class name as the object name. Any tips on how to do this?
[/quote]
All objects deriving from TNamed or implementing a GetName function
will show the class name AND the object name in the context menu (try for instance with a TH1 object)

Rene

I see. So, with no fill, the hover “passes through” to the frame underneath. Now I understand - thank you.

[quote=“brun”]
All objects deriving from TNamed or implementing a GetName function
will show the class name AND the object name in the context menu (try for instance with a TH1 object)
Rene[/quote]

I tried implementing a GetName() function, but it does not work. My c++ is rusty, but it seems it doesn’t work because the context menu code calls the base class’s (TObject) version of GetName, which defaults to the class name. Then I had some problems deriving from both TNamed and TEllipse… but probably I need to play with it more.