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 ?
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.
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
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.
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.