# Using TControlBar to show event by event

**URL:** <https://root-forum.cern.ch/t/using-tcontrolbar-to-show-event-by-event/47646>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 12, 2021, 4:56pm UTC](https://root-forum.cern.ch/t/using-tcontrolbar-to-show-event-by-event/47646 "2021-11-12T16:56:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karl007](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8491ac/32.png) [@Karl007](https://root-forum.cern.ch/u/Karl007)\
**Post date:** [November 12, 2021, 4:56pm UTC](https://root-forum.cern.ch/t/using-tcontrolbar-to-show-event-by-event/47646/1 "2021-11-12T16:56:58Z")

</div>

Hi, I am using TControlBar to show event by event (entry by entry if you like). I already have a function called “show\_entry” and I am trying to call that function inside control bar to make an interactive session. For example:

```auto
	show_entry(0);	
	TControlBar *menu = new TControlBar("vertical","viewer",600,500);
	menu->AddButton("First entry","show_entry(0)","First entry"); // show_entry is a defined function
	menu->AddButton("Next","how?","Type down entry number");
       menu->AddButton("Select entry","hiw?","insert an entry");
	menu->AddButton("Exit",".q","Exit ROOT");
	
	gROOT->SaveContext();
	menu->Show();
	

```

“First” works fine because it is just show\_entry(0), but what is more complicated is to show next entry (Next) and to choose an entry (Select an entry). Not sure how to do it.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 12, 2021, 6:10pm UTC](https://root-forum.cern.ch/t/using-tcontrolbar-to-show-event-by-event/47646/2 "2021-11-12T18:10:37Z")

</div>

Maybe something like this:

```auto
static int curr_entry = 0;

void show_entry(int entry)
{
   curr_entry = entry;
   std::cout << "Entry: " << curr_entry << std::endl;
}

void test_controlbar()
{
   TString macrodir = gROOT->GetMacroDir();
   gROOT->LoadMacro(macrodir+"/Dialogs.C");
   show_entry(0);
   TControlBar *menu = new TControlBar("vertical","viewer",600,500);
   menu->AddButton("First entry","show_entry(0)","First entry"); // show_entry is a defined function
   menu->AddButton("Next entry","show_entry(++curr_entry);","select next entry");
   menu->AddButton("Previous entry","show_entry(--curr_entry);","select previous entry");
   menu->AddButton("Select entry","show_entry(GetIntegerDialog(\"Please type the entry number\", curr_entry));","Type down entry number");
   menu->AddButton("Exit",".q","Exit ROOT");

   gROOT->SaveContext();
   menu->Show();
}

```

---

<div class="post-metadata">

**Author:** ![Karl007](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8491ac/32.png) [@Karl007](https://root-forum.cern.ch/u/Karl007)\
**Post date:** [November 13, 2021, 2:03pm UTC](https://root-forum.cern.ch/t/using-tcontrolbar-to-show-event-by-event/47646/3 "2021-11-13T14:03:28Z")

</div>

> [@bellenot](#):
>
> `show_entry`

It works fine. Thank you 🙂
