Codenameone嵌套Lead组件

Codenameone nested Lead component

我正在尝试将带有主要组件的 Container A 添加到另一个 Container B(带有自己的主要组件)中。但是,我无法弄清楚如何让 Container A 单独处理来自 Container B 的指针事件。

以下代码是我到目前为止所做的(但失败了)。总结一下,在Lead component A上调用setBlockLead(true)会导致Lead component A调用自己的action listener,但不会影响Container A的其余部分。

    Container conB = new Container();
    Button leadB = new Button("b");
    leadB.addActionListener((evt) -> {
        System.out.println("Lead B");
    });
    conB.setLeadComponent(leadB);

    Container conA = new Container(BoxLayout.y());
    Button leadA = new Button("a");
    leadA.addActionListener((evt) -> {
        System.out.println("Lead A");
    });
    conA.add(leadA);
    conA.add("Another label");
    conB.add(leadB).add(conA);

    conA.setBlockLead(true); //This has no effect
    conA.setLeadComponent(leadA); //Apparently no effect either
    leadA.setBlockLead(true); 
    //Clicking on leadA (and only leadA) will print "Lead A", but 
    //Clicking on Label will not 

这样做的主要原因是要在文字的上方和下方显示带有图像的按钮,这与单击容器其余部分的行为不同。

请指教。

我们不支持嵌套前导组件,您可以使用 setLeadComponent(null) 禁用内部容器的前导组件,但嵌套将不起作用,因为前导组件层次结构中有很多假设。