Hi Christian,
I'm currently rewriting some TG-classes.
I'll try to look at "focus problem" in detail.
Regards. Valeriy
Christian Holm Christensen wrote:
> Hi Valeriy et al,
>
> On Tue, 19 Mar 2002 14:00:36 +0100
> Valeriy Onuchin <Valeri.Onoutchine@cern.ch> wrote
> concerning "Re: [ROOT] Tab-key":
> > Hi Ivan,
> >
> > Ivan Kronkvist wrote:
> >
> > > How can I get my ROOT-GUI program to capture the Tab-key and
> > > move to the next TextEntry field or button?
> > >
> >
> > Check TabPressed signal
> >
> > http://root.cern.ch/root/html/TGTextEntry.html#TGTextEntry:TabPressed
> >
> > to move focus to another textentry use SetFocus method
> >
> > http://root.cern.ch/root/html/TGTextEntry.html#TGTextEntry:SetFocus
>
> Is there a way to put focus onto any kind of widget, so that the next
> keyboard event will be for that widget? I was thinking of something
> like a dialog box:
>
> class MyDialog
> {
>
> RQ_OBJECT("MyDialog")
>
> private:
> TGMainFrame* fMain;
> TGGroupFrame* fTopFrame;
> TGTextEntry* fEntry;
> TGHButtonGroup* fButtons;
> TGTextButton* fOkButton;
> TGTextButton* fCancelButton;
> TGFrame* fCurrent;
> public:
> MyDialog()
> {
> fMain = new TGMainFrame(gClient->GetRoot(), 1, 1);
> fTopFrame = new TGGroupFrame(fMain, "Hello");
> fEntry = new TGTextEntry(fTopFrame, "Hello World");
> fButtons = new TGHButtonGroup(fMain);
> fOkButton = new TGTextButton(fButtons,"&Ok");
> fCancelButton = new TGTextButton(fButtons,"&Cancel");
>
> fMain->AddFrame(fTopFrame);
> fMain->AddFrame(fButtons);
> fTopFrame->AddFrame(fEntry);
>
> fEntry->Connect("ReturnPressed()", "MyDialog",
> this, "HandleReturn()");
> fEntry->Connect("TabPressed()", "MyDialog",
> this, "HandleTab()");
> fOkButton->Connect("TabPressed()", "MyDialog",
> this, "HandleTab()");
> fOkButton->Connect("ReturnPressed()", "MyDialog",
> this, "HandleReturn()");
> fCancelButton->Connect("TabPressed()", "MyDialog",
> this, "HandleTab()");
> fCancelButton->Connect("ReturnPressed()", "MyDialog",
> this, "HandleReturn()");
> fButtons->Connect("Clicked(Int_t)", "MyDialog",
> this, "HandleClicked(Int_t)");
>
> fCurrent = fEntry;
> fEntry->SetFocus();
>
> fMain->MapSubwindows();
> fMain->Resize(fMain->GetDefaultSize());
> fMain->MapWindow();
> }
> void HandleTab()
> {
> if (fCurrent == fEntry)
> fCurrent = fOkButton;
> else if (fCurrent == fOkButton)
> fCurrent = fCancelButton;
> else if (fCurrent == fCancelButton)
> fCurrent = fEntry;
> fCurrent->SetFocus();
> }
> void HandleReturn()
> {
> if (fCurrent == fEntry)
> fCurrent = fOkButton;
> else if (fCurrent == fOkButton) {
> cout << fEntry->GetText() << endl;
> gApplication->Terminate();
> }
> else if (fCurrent == fCancelButton)
> gApplication->Terminate();
> }
> void HandleClicked(Int_t id)
> {
> if (id = 1) {
> cout << fEntry->GetText() << endl;
> gApplication->Terminate();
> }
> gApplication->Terminate();
> }
> };
>
> That would really make the ROOT UI behave much like anyother UI out
> there. Perhaps, on Tab, the composite frames should cycle through
> it's children, giving focus to those that want it, and if nobody wants
> it, or reach the end, or whatever, give the event to the parent, so
> that the parent may choose the next in line for the event.
>
> Yours,
>
> Christian Holm Christensen -------------------------------------------
> Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91
> DK-2200 Copenhagen N Cell: (+45) 28 82 16 23
> Denmark Office: (+45) 353 25 305
> Email: cholm@nbi.dk Web: www.nbi.dk/~cholm
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET