[ROOT] Advice on using TGMenuBar/TGPopupMenu

From: James Peachey (peachey@bigband.gsfc.nasa.gov)
Date: Wed Dec 20 2000 - 18:06:07 MET


Hi,

Since this is my first time writing to roottalk, let me start by
saying thank you for making available such a great software system!
I very much enjoy using Root, and I'm very impressed at what it
can do.

At the moment I'm using the GUI classes, and I'm having some trouble
getting my menubar to work correctly. I based my approach on the code
in TRootCanvas, which suggests that the following should work:

  // file menu
  mFileMenu = new TGPopupMenu(fClient->GetRoot());
  mFileMenu->AddEntry(new TGHotString("&Save"), kITG_ID_MENUSAVE);
  mFileMenu->Associate(this);

  // menubar
  mMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame | kRaisedFrame);
  mMenuBar->AddPopup("&File", mFileMenu, TopLeftHints);
  AddFrame(mMenuBar, TopLeftExpandXHints);

I also added code to ProcessMessage() to handle the event for the
TGPopupMenu for parm1 == kITG_ID_MENUSAVE. I should mention that the
code above appears in the initialization for a class derived from
TGMainFrame.

When I do this, I get a "File" pull-down menu which pops up
a "Save" option when it is clicked -- so far so good. However, it
is impossible actually to *select* the "Save" option, that is, the
code in ProcessMessage() is never executed even when one selects
"Save" with the mouse.

I also tried constructing the TGPopupMenu object using "this" instead
of "fClient->GetRoot()". In that case, the code in ProcessMessage()
is called when one selects "Save", but the menu doesn't look right
when my application starts; the menu appears to be "pulled down"
when the main window first pops up.

Any ideas what I am doing wrong?

Thanks,
James



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET