Multiple entry selection & context menus in TGListBox

Hi,

I have two questions regarding TGListBox.

  1. in MultipleSelections mode, is there an option or a way to have the following behaviour: left-click on each item selects it, deselecting previous item; Ctrl-left-click adds object to selection; Shift-left-click selects all items in list from previous selection to new one ?

  2. is it possible to have the following behaviour : right-clicking an item opens the context menu of the corresponding object ?

Thanks for any help

PS. For the moment, I think that the answer to 1 and 2 is “write some code”, but I want to be sure I haven’t missed something before I start.

John

Hi John,

The behavior you have explained in 1) and 2) is not available. The implemented keyboard navigation is as follows:
Ctrl+A - select all list box entries
PgUp - one page up
PgDn - one page down
Up arrow - one entry up
Down arrow - one entry down

Cheers, Ilka

Thanks for the confirmation - if I manage to write a TGListBox class with this behaviour as an option, I’ll let you know.

All the best
John

Hi,

are there any news on this topic?

I tried to understand the Context Menu within the TGListBox. The ClassIndex says there are four functions indicated with // MENU which should automatically appear in a context menu. Neither my personal implementation nor the TGListBox in “Tab4” of the “DialogTest” of “guitest.C” has a context menu.

Can somebody explain or help?

cheers

Jens

Hi Jens,

There is no context menu in TGListBox. You have to implement it yourself…
Here is a short example, using signal/slot mechanism:

   // connect the listbox container "ProcessedEvent()" signal to 
   // our "LBCEvent()" slot
   fListBox->GetContainer()->Connect("ProcessedEvent(Event_t*)",
                     "MyMainFrame", this, "LBCEvent(Event_t*)");

void MyMainFrame::LBCEvent(Event_t *ev)
{
   Int_t px = 0, py = 0;
   Window_t wtarget;
   // only popup context menu if user clicked with the right button
   if (ev->fType == kButtonRelease && ev->fCode == kButton3) {
      // translate coordinates from the event window (the list box container)
      // to the root (desktop) window
      gVirtualX->TranslateCoordinates(ev->fWindow,
                                      gClient->GetDefaultRoot()->GetId(), 
                                      ev->fX, ev->fY, px, py, wtarget);
      // popup the context menu, automatically using the TGListBox methods 
      // having // *MENU* as comment
      fContextMenu->Popup(px, py, fListBox);
   }
}

Let me know if it is not clear enough, or if you need more informations.

Cheers, Bertrand.