How to change state of TGSplitButton?


I would like to change the state of a (truly split) TGSplitButton. I could not find any method to influence the state of the button (i.e. which of the menu items is displayed on the button). I have also tried (brute force) via the menu attached to the TGSplitButton, e.g. deleting a menu entry and later adding it, but this only seems to confuse the TGSplitButton, ending in a segementation violation.


    fMenu = new TGPopupMenu(gClient->GetRoot());
    fMenu->AddEntry("Item 1", M_ITEM1);
    fMenu->AddEntry("Item 2", M_ITEM2);
    fSplitButton = new TGSplitButton(fFrame, new TGHotString("Split Button"), 
					fMenu, kTRUE, splitButtonID);

    fSplitButton->Connect("ItemClicked(Int_t)", "MyClass", this, "DoButton(Int_t)");
    fMenu->Connect("Activated(Int_t)", "MyClass", this,"DoMenu(Int_t)");

Now, what I want is when the user selects “Item2”, something happens, but the button STAYS on item1! Therefore, in DoMenu(), I try something like

    case M_ITEM2:
        // launch some window
        new Dialog(bla);
        // make sure fSplitButton stays on Item1 - the only way I can think of:
        TGHotString* label = fMenu->GetEntry(M_ITEM2)->GetLabel();
        fMenu->AddEntry(label, M_ITEM2); 

But this results in a seg. viol. Is there really no way to change the status of a split button other than clicking on it? Am I using the wrong widget for this? (If I could change its state, it would be the perfect widget for my application…) Does anyone have an idea?

Many thanks,


Hi Thomas,
You are right, there is no API to do this. We will put it in our ToDo list.
Cheers, Bertrand.