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 public:
6  FWPopupMenu(const TGWindow* p = nullptr, UInt_t w = 10, UInt_t h = 10, UInt_t options = 0)
7  : TGPopupMenu(p, w, h, options) {
8  AddInput(kKeyPressMask);
9  }
10 
11  // virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
12  // {
13  // TGPopupMenu::PlaceMenu(x, y, stick_mode, grab_pointer);
14  // gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
15  // }
16 
17  void PoppedUp() override {
18  TGPopupMenu::PoppedUp();
19  gVirtualX->SetInputFocus(fId);
20  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
21  }
22 
23  void PoppedDown() override {
24  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kFALSE);
25  TGPopupMenu::PoppedDown();
26  }
27 
28  Bool_t HandleKey(Event_t* event) override {
29  if (event->fType != kGKeyPress)
30  return kTRUE;
31 
32  UInt_t keysym;
33  char tmp[2];
34  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
35 
36  TGMenuEntry* ce = fCurrent;
37 
38  switch (keysym) {
39  case kKey_Up: {
40  if (ce)
41  ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
42  while (ce && ((ce->GetType() == kMenuSeparator) || (ce->GetType() == kMenuLabel) ||
43  !(ce->GetStatus() & kMenuEnableMask))) {
44  ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
45  }
46  if (!ce)
47  ce = (TGMenuEntry*)GetListOfEntries()->Last();
48  Activate(ce);
49  break;
50  }
51  case kKey_Down: {
52  if (ce)
53  ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
54  while (ce && ((ce->GetType() == kMenuSeparator) || (ce->GetType() == kMenuLabel) ||
55  !(ce->GetStatus() & kMenuEnableMask))) {
56  ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
57  }
58  if (!ce)
59  ce = (TGMenuEntry*)GetListOfEntries()->First();
60  Activate(ce);
61  break;
62  }
63  case kKey_Enter:
64  case kKey_Return: {
65  Event_t ev;
66  ev.fType = kButtonRelease;
67  ev.fWindow = fId;
68  return HandleButton(&ev);
69  }
70  case kKey_Escape: {
71  fCurrent = nullptr;
72  void* dummy = nullptr;
73  return EndMenu(dummy);
74  }
75  default: { break; }
76  }
77 
78  return kTRUE;
79  }
80 };
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void PoppedUp() override
Definition: FWPopupMenu.cc:17
const double w
Definition: UKUtility.cc:23
Bool_t HandleKey(Event_t *event) override
Definition: FWPopupMenu.cc:28
void PoppedDown() override
Definition: FWPopupMenu.cc:23
bool ev
tmp
align.sh
Definition: createJobs.py:716
FWPopupMenu(const TGWindow *p=nullptr, UInt_t w=10, UInt_t h=10, UInt_t options=0)
Definition: FWPopupMenu.cc:6
Definition: event.py:1