Re: [ROOT] TControlBar and cin (no echo)

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Oct 26 2001 - 19:15:35 MEST


Hi Isidro,

 have a look at the $ROOTSYS/tutorials/dialogs.C script to get input dialog
boxes.

-- Fons



Isidro.Gonzalez.Caballero@cern.ch wrote:
> 
> Hi,
>         I want to build a contolbar with buttons to launch several macros
> and to also set some global variables (number of events, center of mass
> energy, target material,...). I would like to get the values for this
> variables through a dialog box, but I don't know an easy way to do it
> (suggestions?). I decided then to get the information from the standard
> input, but then I get no echo. I have attached a small macro showing it
> (just click in the "# Events" button and try to type anything). Any
> solutions?
> 
>         Cheers,
> 
>                 Isidro
> 
> +---------------------------+--------------------------------+
> | Isidro González Caballero | mailto:Isidro.Gonzalez@cern.ch |
> | CERN-EP / Mailbox: F28010 | http://home.cern.ch/~iglez/    |
> | 1211 Geneva 23            |               -o-              |
> | Switzerland               | Tel: +41 22 76 73060, 73316    |
> +---------------------------+--------------------------------+
> 
>   --------------------------------------------------------------------------------
> //////////////////////////////////////////////
> // Class to hold event data information. Works
> // like a store of global variables
> class EventData {
>  public:
>   EventData(){
>     nEvents = -1;
>     cout << "* Creating EventData with default values." << endl;
>   }
> 
>   static void SetNEvents(Int_t n) { nEvents=n; }
>   static Int_t GetNEvents() {return nEvents;}
> 
>   static void Dump() {
>     cout << "* EventData values:" << endl;
>     cout << "\t- NEvents = " << nEvents << endl;
>   }
> 
>  protected:
>   static Int_t nEvents;
> };
> 
> ///////////////////////////////////////////
> // Get from normal input the number of events
> // to be processed.
> void FindNEvents() {
>   Int_t nev;
>   cout << endl
>        << "*******************************************************************"
>        << endl;
>   cout << "Input number of events to be processed (-1 for ALL): " << endl;
>   cin  >>  nev;
>   cout << "*******************************************************************"
>        << endl;
>   EventData::SetNEvents(nev);
>   EventData::Dump();
> }
> 
> ///////////////////////////////////////////
> // Build Control bar
> void Trial() {
>   EventData* d = new EventData;
>   d->Dump();
> 
>   gROOT->Reset();
>   TControlBar* bar = new TControlBar("vertical", "Tools");
> 
>   bar->AddButton("ROOT Browser",
>                  "new TBrowser;",
>                  "Start the ROOT Browser");
> 
>   bar->AddButton("# Events",
>                  "FindNEvents();",
>                  "Set the number of events to be processed");
> 
>   bar->Show();
> }
> 

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:04 MET