CMS 3D CMS Logo

FWPopupMenu.cc
Go to the documentation of this file.
1 #include "TGMenu.h"
2 #include "KeySymbols.h"
3 
4 class FWPopupMenu : public TGPopupMenu
5 {
6 public:
7  FWPopupMenu(const TGWindow* p=0, UInt_t w=10, UInt_t h=10, UInt_t options=0) :
8  TGPopupMenu(p, w, h, options)
9  {
10  AddInput(kKeyPressMask);
11  }
12 
13  // virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
14  // {
15  // TGPopupMenu::PlaceMenu(x, y, stick_mode, grab_pointer);
16  // gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
17  // }
18 
19  virtual void PoppedUp() override
20  {
21  TGPopupMenu::PoppedUp();
22  gVirtualX->SetInputFocus(fId);
23  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
24 
25  }
26 
27  virtual void PoppedDown() override
28  {
29  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kFALSE);
30  TGPopupMenu::PoppedDown();
31  }
32 
33  virtual Bool_t HandleKey(Event_t* event) override
34  {
35  if (event->fType != kGKeyPress) return kTRUE;
36 
37  UInt_t keysym;
38  char tmp[2];
39  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
40 
41  TGMenuEntry *ce = fCurrent;
42 
43  switch (keysym)
44  {
45  case kKey_Up:
46  {
47  if (ce) ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
48  while (ce && ((ce->GetType() == kMenuSeparator) ||
49  (ce->GetType() == kMenuLabel) ||
50  !(ce->GetStatus() & kMenuEnableMask)))
51  {
52  ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
53  }
54  if (!ce) ce = (TGMenuEntry*)GetListOfEntries()->Last();
55  Activate(ce);
56  break;
57  }
58  case kKey_Down:
59  {
60  if (ce) ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
61  while (ce && ((ce->GetType() == kMenuSeparator) ||
62  (ce->GetType() == kMenuLabel) ||
63  !(ce->GetStatus() & kMenuEnableMask)))
64  {
65  ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
66  }
67  if (!ce) ce = (TGMenuEntry*)GetListOfEntries()->First();
68  Activate(ce);
69  break;
70  }
71  case kKey_Enter:
72  case kKey_Return:
73  {
74  Event_t ev;
75  ev.fType = kButtonRelease;
76  ev.fWindow = fId;
77  return HandleButton(&ev);
78  }
79  case kKey_Escape:
80  {
81  fCurrent = 0;
82  void *dummy = 0;
83  return EndMenu(dummy);
84  }
85  default:
86  {
87  break;
88  }
89  }
90 
91  return kTRUE;
92  }
93 };
virtual void PoppedUp() override
Definition: FWPopupMenu.cc:19
const double w
Definition: UKUtility.cc:23
bool ev
FWPopupMenu(const TGWindow *p=0, UInt_t w=10, UInt_t h=10, UInt_t options=0)
Definition: FWPopupMenu.cc:7
virtual Bool_t HandleKey(Event_t *event) override
Definition: FWPopupMenu.cc:33
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Definition: event.py:1
virtual void PoppedDown() override
Definition: FWPopupMenu.cc:27