Re: Keyboard interaction

Rene Brun (Rene.Brun@cern.ch)
Thu, 24 Jun 1999 17:30:22 +0200 (METDST)


Hi Thomas,
You can use the TTimer class. we give examples of this class
in the test applications Aclock, Tetris, Hello in the $ROOTSYS/test
directory. The class TTreeViewer, for example, uses this feature.
While something executes, you can still type & execute commands
in parallel.
I suggest you look at the code of TTree::EntryLoop to see how
this works:
You will see a TProcessEventTimer created at the start.
Then inside the loop, we have a control like:
if (timer && timer->ProcessEvents()) break;
if (gROOT->IsInterrupted()) break;

The timer->ProcessEvents function will flush all current events
(mouse, keybord, pipe, socket, X, etc).
The TTreeViewer class show examples interrupting the current event loop
by pushing a "BREAK" button, calling gROOT->SetInterrupt.

Rene Brun

On Thu, 24 Jun 1999, Thomas Eberl wrote:

> Dear rooters,
>
> is there a class in ROOT that allows to interact with the keyboard ?
> E.g., I want to exit an infinite loop in my program by pressing a button
> on my keyboard and to achieve this I'd like to use a ROOT class.
> Additionally, this should not block the program, i.e. it should not stop
> and wait for input, but it should just try to look to the keyboard
> buffer whether a key was pressed or not.
>
> Thank you for any comments on this
>
> Thomas
> --
> Thomas Eberl Phone: (+49 89) 289 1 2425
> Physik-Department E12, Technische Universitaet Muenchen
> James-Franck-Strasse *** 85748 Garching b. Muenchen
> Email: Thomas.Eberl@physik.tu-muenchen.de
>