Closed jsfan3 closed 5 years ago
Test case to be more clear:
Form hi = new Form("Popup test", BorderLayout.absolute());
AutoCompleteTextField autocomplete = new AutoCompleteTextField("1", "2", "3");
Button tapMe = new Button("Tap me leaving the popup opened");
tapMe.addActionListener(l -> {
hi.replace(autocomplete, new Label("other content"), null);
hi.revalidate();
});
hi.add(BorderLayout.CENTER, autocomplete);
hi.add(BorderLayout.NORTH, tapMe);
hi.show();
If you type "2" in the AutoCompleteTextField and then press the button, you will get the following wrong UI, because the popup is still shown without any chance to remove it:
What I'm asking is a new method closePopup()
, to be used so:
tapMe.addActionListener(l -> {
autocomplete.closePopup();
hi.replace(autocomplete, new Label("other content"), null);
hi.revalidate();
});
or, alternatively, a fix that automatically close the popup if the AutoCompleteTextField is removed or replaced (maybe this is better).
There was a bug in the deinitialization code that caused the popup removal to fail. I have fixed this so that the popup is automatically removed.
I've added a sample for this issue as well.
Thank you
Can you please add an API to programmatically close the popup of an AutoCompleteTextField, when the popup is shown?
My problem is that I have a Contacts page in which the user can autocomplete its address and other data (there are several AutoCompleteTextField in the same Form)... but, if he/she leaves the popup opened (without tapping any item of the list) and press a Button that removes the AutoCompleteTextFields to show other content (in the same Form), the popup remains like in the following screenshot. I thought that a solution is to close programmatically any popup shown, if there is one.