Changeset 739 in josm


Ignore:
Timestamp:
2008-07-28T11:26:26+02:00 (16 years ago)
Author:
stoecker
Message:

fixed autocompletion again to also work for Windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/AutoCompleteComboBox.java

    r736 r739  
    3939                        if(selecting || (offs == 0 && str.equals(getText(0, getLength()))))
    4040                                return;
     41                        boolean initial = (offs == 0 && getLength() == 0);
    4142                        super.insertString(offs, str, a);
    4243
     
    4849
    4950                        int size = getLength();
     51                        int start = offs+str.length();
     52                        int end = start;
    5053                        String curText = getText(0, size);
    5154                        // lookup and select a matching item
    5255                        Object item = lookupItem(curText);
     56                        setSelectedItem(item);
     57                        if(initial)
     58                                start = 0;
    5359                        if (item != null) {
    5460                                String newText = item.toString();
     
    5965                                        super.insertString(0, newText, a);
    6066                                        selecting = false;
    61                                         JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent();
    62                                         editor.setSelectionStart(size);
    63                                         editor.setSelectionEnd(getLength());
     67                                        start = size;
     68                                        end = getLength();
    6469                                }
    6570                        }
    66                         setSelectedItem(item);
     71                        JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent();
     72                        editor.setSelectionStart(start);
     73                        editor.setSelectionEnd(end);
    6774                }
    6875
     
    95102                for (String elem : elems) model.addElement(elem);
    96103                this.getEditor().setItem(oldValue);
    97                 this.getEditor().selectAll();
    98104        }
    99105}
Note: See TracChangeset for help on using the changeset viewer.