I am working off of the tutorial gui/guitest.C, and have edited it to enabled two embedded canvas’s in the main window inside of a CompositeFrame. I have edited the file->open to open a root file and fill a combobox with the histograms that are in the root file and when one of the histograms are selected from the combobox, it is drawn in the first of the embedded canvas’s. This all works very well but I would like to be able to get keypress events when the mouse is over the histogram. I can get mouse movements and mouse clicks, and depending on how I setup the connect(), I can get key presses in the embedded canvas, but once the histogram is drawn that goes away. I want to be able to get information on the current location of the cursor and store that depending on which key is pressed and keep the mouse movement information.
If I define, not using the gui classes, a TCanvas and connect it to ProcessedEvents(), with
TCanvas c1 = new TCanvas("c1", "GAMANAL-like Fit to Gamma-Ray Peak", 750, 700); c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "HFitter", h1, "ExecuteEvent(Int_t,Int_t,Int_t,TObject*)");
Where the HFitter class controls histogram fitting and handles whether events are keypresses or mouse clicks to do various things, and h1 is a filled & drawn histogram. This works to handle BOTH keypresses and mouse clicks/movements. But not for when I have a histogram in an embedded canvas.
I have tried the following in my version of the guitest.C tutorial
fEc1 = new TRootEmbeddedCanvas("ec1", fF5, 100, 400); c1 = fEc1->GetCanvas(); c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "TestMainFrame", this, "ExecuteEvent(Int_t,Int_t,Int_t,TObject*)"); OR IN ANOTHER PLACE fHpx=(TH1F *)tfile->Get(T); fHpx->Draw(); c1 = fEc1->GetCanvas(); c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "TestMainFrame", fHpx, "ExecuteEvent(Int_t,Int_t,Int_t,TObject*)");
I have attached my code, the above two attempts can be found at lines 408 & 498 respectively. I have tried to AddInput() to the Embedded Canvas but that did not seem to help.
Any help to figure out how to enable key presses would be appreciated. I have searched the forums and found some hints but nothing that has yielded a solution.
guitest.C (28.1 KB)
_Platform:MacOSX Mojave 10.14.2
Compiler: Not Provided