Skip to content

Broken Behaviour on AutoCompleteTextComponent #3349

@Ngosti2000

Description

@Ngosti2000

@shannah Currently on Android (Not able to reproduce this on the simulator) when selecting an item on the autocompletetextcomponent causes the field to disfigure the selected item on the field itself by adding/subtracting letters of the selected item.

Below is the test case and screenshot
WhatsApp Image 2021-01-18 at 23 02 34
WhatsApp Image 2021-01-18 at 23 04 05

import static com.codename1.ui.CN.*;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.io.Log;
import com.codename1.ui.Toolbar;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.AutoCompleteTextComponent;
import com.codename1.ui.list.DefaultListModel;
import com.codename1.ui.list.ListModel;

public class MyApplication {
    private Form current;
    private Resources theme;

    public void init(Object context) {
        // use two network threads instead of one
        updateNetworkThreadCount(2);

        theme = UIManager.initFirstTheme("/theme");

        // Enable Toolbar on all Forms by default
        Toolbar.setGlobalToolbar(true);

        // Pro only feature
        Log.bindCrashProtection(true);

        addNetworkErrorListener(err -> {
            // prevent the event from propagating
            err.consume();
            if(err.getError() != null) {
                Log.e(err.getError());
            }
            Log.sendLogAsync();
            Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
        });        
    }
    
    public void start() {
        if(current != null){
            current.show();
            return;
        }
        Form hi = new Form("Hi World", BoxLayout.y());
       
        AutoCompleteTextComponent.AutoCompleteFilter po = text -> {
            if (text.trim().length() <= 1) {
               
                return false;
            }
           
            return true;
        };
        ListModel<String> li=new DefaultListModel<>("Red","Green","Blue");
        AutoCompleteTextComponent act = new AutoCompleteTextComponent(li,po);
        
        hi.add(act);
        hi.show();
    }

    public void stop() {
        current = getCurrentForm();
        if(current instanceof Dialog) {
            ((Dialog)current).dispose();
            current = getCurrentForm();
        }
    }
    
    public void destroy() {
    }

}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions