Changeset 739 in josm
- Timestamp:
- 2008-07-28T11:26:26+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AutoCompleteComboBox.java
r736 r739 39 39 if(selecting || (offs == 0 && str.equals(getText(0, getLength())))) 40 40 return; 41 boolean initial = (offs == 0 && getLength() == 0); 41 42 super.insertString(offs, str, a); 42 43 … … 48 49 49 50 int size = getLength(); 51 int start = offs+str.length(); 52 int end = start; 50 53 String curText = getText(0, size); 51 54 // lookup and select a matching item 52 55 Object item = lookupItem(curText); 56 setSelectedItem(item); 57 if(initial) 58 start = 0; 53 59 if (item != null) { 54 60 String newText = item.toString(); … … 59 65 super.insertString(0, newText, a); 60 66 selecting = false; 61 JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent(); 62 editor.setSelectionStart(size); 63 editor.setSelectionEnd(getLength()); 67 start = size; 68 end = getLength(); 64 69 } 65 70 } 66 setSelectedItem(item); 71 JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent(); 72 editor.setSelectionStart(start); 73 editor.setSelectionEnd(end); 67 74 } 68 75 … … 95 102 for (String elem : elems) model.addElement(elem); 96 103 this.getEditor().setItem(oldValue); 97 this.getEditor().selectAll();98 104 } 99 105 }
Note:
See TracChangeset
for help on using the changeset viewer.