#include "TGFrame.h" #include "TGButton.h" #include "TRootEmbeddedCanvas.h" #include class TestFrame : public TGMainFrame { public: TestFrame(const TGWindow * p, UInt_t w, UInt_t h); void CloseWindow(); void PrintKey(Event_t*); ClassDef(TestFrame,1); }; TestFrame::TestFrame(const TGWindow * p, UInt_t w, UInt_t h) : TGMainFrame(p,w,h) { Connect("CloseWindow()", "TestFrame", this, "CloseWindow()"); Connect("ProcessedEvent(Event_t*)", "TestFrame", this, "PrintKey(Event_t*)"); SetCleanup(kDeepCleanup); AddInput(kKeyPressMask); TGHorizontalFrame *f = new TGHorizontalFrame(this, w,h); TGTextButton *button = new TGTextButton(f,"foo"); f->AddFrame(button); AddFrame(f); MapSubwindows(); Resize(GetDefaultSize()); MapWindow(); } void TestFrame::PrintKey(Event_t* e){ const unsigned ESCAPE = 9; std::cerr << e->fCode << '\n'; if(e->fType == kGKeyPress && e->fCode == ESCAPE){ CloseWindow(); } } void TestFrame::CloseWindow(){ delete this; }