The image number 57 shows the list of articles that have already been selected. In order to include a new article, it is necessary to write the name in the search field that appears at the top (txBusqueda).
Image 58 shows the information search by typing the word "sa" in the "txBusqueda" field.
As you can see, the list of containers covers the search field and does not allow it to slide vertically.
Image 60 shows the search for information by typing the word "sal" in the "txBusqueda" field.
Although the "txBusqueda" field is not visible, it allows you to continue writing and the list does not appear below the mentioned field.
To filter on the "txBusqueda" field I have the following code:
txBusqueda.addDataChangeListener((i1, i2) -> {
String t = txBusqueda.getText();
if (t.length() < 1) {
for (Component cmp : popup) {
Orden2 o2 = (Orden2) cmp.getClientProperty("registro");
if (o2.enPedido.get()) {
cmp.setHidden(false);
cmp.setVisible(true);
} else {
cmp.setHidden(true);
cmp.setVisible(false);
}
}
} else {
t = t.toLowerCase();
for (Component cmp : popup) {
Orden2 o2 = (Orden2) cmp.getClientProperty("registro");
boolean show = false;
String val = null;
if (cmp instanceof Container) {
val = (String) cmp.getClientProperty("busqueda");
}
show = val != null && val.toLowerCase().indexOf(t) > -1 && !o2.enPedido.get();
cmp.setHidden(!show);
cmp.setVisible(show);
}
}
popup.animateLayout(250);
});
To add the popup window I have the following code:
private void addPopup() {
final Form f = getComponentForm();
popup.removeAll();
popup = contenedorOrden2(false);
popup.setScrollableY(true);
byte[] units = popup.getStyle().getMarginUnit();
if (units != null) {
units[Component.LEFT] = Style.UNIT_TYPE_PIXELS;
units[Component.TOP] = Style.UNIT_TYPE_PIXELS;
popup.getAllStyles().setMarginUnit(units);
}
popup.setOwner(txBusqueda);
int popupHeight = txBusqueda.getAbsoluteY() + txBusqueda.getHeight();
popup.setPreferredW(getWidth());
popup.setWidth(getWidth());
popup.layoutContainer();
Style sPopup = popup.getUnselectedStyle();
sPopup.setBgTransparency(255);
sPopup.setBgColor(0x800080);
sPopup.setMarginUnit(Style.UNIT_TYPE_DIPS);
sPopup.setPaddingUnit(Style.UNIT_TYPE_DIPS);
sPopup.setMargin(1, 1, 1, 1);
if (f != null) {
if (popup.getParent() == null) {
Container lay = f.getLayeredPane(txBusqueda.getClass(), false);
lay.setLayout(new LayeredLayout());
Container wrapper = new Container();
wrapper.add(popup);
lay.addComponent(wrapper);
}
f.revalidate();
}
}
How do I make the popup window stay below the "txBusqueda" field, stay centered and allow it to scroll vertically?