How to make a Container draggable even if it is containing a SpanButton?

Viewed 24

It seems the use of a SpanButton in a draggable Container breaks something since the Container can no longer be dragged. What can be done to still have the Container draggable even with a SpanButton?

I've tried to understand the CN1 code, but difficult for me to follow. My guess is that the culpit is that a SpanButton makes its internal Button Lead of its own Container, but I don't see why that should prevent containing Containers to have another Lead at their level.

I also noticed in the test code below (1st example) that setting a Container draggable doesn't work unless some (arbitrary?) content within it is made Lead. Not sure why, I haven't found any explanation in the documentation or here on SO.

Form hi = new Form("SpanButton ", BoxLayout.y());
{
    Button button1 = new Button("Normal Button, no lead");
    Container draggableContainer = BorderLayout.centerCenterEastWest(button1, new Button("Other"), null);
    draggableContainer.setDraggable(true);
    hi.add(draggableContainer);
    //observation: container not draggable 
}
{
    Button button2 = new Button("Normal Button, lead");
    Container draggableContainer = BorderLayout.centerCenterEastWest(button2, new Button("Other"), null);
    draggableContainer.setDraggable(true);
    draggableContainer.setLeadComponent(button2); //undocumented why a draggable Container doesn't work without a LeadComponent
    hi.add(draggableContainer);
    //observation: container draggable 
}
{
    SpanButton button3 = new SpanButton("SpanButton, lead");
    Container draggableContainer = BorderLayout.centerCenterEastWest(button3, new Button("Other"), null);
    draggableContainer.setDraggable(true);
    draggableContainer.setLeadComponent(button3);
    hi.add(draggableContainer);
    //observation: container not draggable (well, "Other" can initiate a drag, but container disappears
}
hi.show();
1 Answers
Related