My plugin:
public class TestCustomUIPanelPlugin extends BaseCustomUIPanelPlugin {
protected String name;
public TestCustomUIPanelPlugin(String name) {
this.name = name;
}
@Override
public void buttonPressed(Object buttonId) {
log.info(String.format("Button %s pressed picked up by panel plugin %s", buttonId, name));
}
}
Test code 1:
public static void panelTest(InteractionDialogAPI dialog) {
VisualPanelAPI vp = dialog.getVisualPanel();
CustomUIPanelPlugin plugin = new TestCustomUIPanelPlugin("Outer");
CustomPanelAPI panel = vp.showCustomPanel(600, 800, plugin);
TooltipMakerAPI tooltip = panel.createUIElement(400, 96, false);
tooltip.addButton("test", "my button ID", 60, 24, 3);
panel.addUIElement(tooltip).inTL(0, 0);
}
Result: "Button my button ID pressed picked up by panel plugin Outer"
OK, fine
Test code 2: Instead of adding the button to the outer panel, we nest it inside another panel:
CustomUIPanelPlugin plugin2 = new TestCustomUIPanelPlugin("Inner");
boolean usePlugin2 = true;
CustomPanelAPI subPanel = panel.createCustomPanel(400, 96, usePlugin2 ? plugin2 : null);
panel.addComponent(subPanel).inTL(0, 0);
TooltipMakerAPI tooltip = subPanel.createUIElement(400, 96, false);
tooltip.addButton("test", "my button ID", 60, 24, 3);
subPanel.addUIElement(tooltip).inTL(0, 0);
Result: "Button my button ID pressed picked up by panel plugin Inner"
Actually causes some problems for my current code, but fine, this is valid.
Test code 3: Same as before, but we set usePlugin2 to false, so the inner panel has no plugin.
Result: (no log message)