[josm-dev] Possible fix for auto-complete annoyance
Karl Newman
siliconfiend at gmail.com
Sat Oct 27 06:20:41 BST 2007
I was able to fix the auto-complete problem by moving the logic that
selects the untyped substring of the match to a point after the
selection is set. I think with the Windows theme, setting the selected
item automatically causes the entire field to be highlighted.
This does move the selection logic out of an "if" block, so I don't
know about unintended consequences, but I didn't notice anything
broken. Anyway, take a look at this patch and see if it could work (I
didn't try it with any other themes).
Karl
Index: C:/Documents and
Settings/KNewman/workspace/JOSM/src/org/openstreetmap/josm/tools/AutoCompleteComboBox.java
===================================================================
--- C:/Documents and
Settings/KNewman/workspace/JOSM/src/org/openstreetmap/josm/tools/AutoCompleteComboBox.java (revision
430)
+++ C:/Documents and
Settings/KNewman/workspace/JOSM/src/org/openstreetmap/josm/tools/AutoCompleteComboBox.java (working
copy)
@@ -50,12 +50,12 @@
// remove all text and insert the completed string
super.remove(0, getLength());
super.insertString(0, item.toString(), a);
- // select the completed part
- JTextComponent editor =
(JTextComponent)comboBox.getEditor().getEditorComponent();
- editor.setSelectionStart(offs + str.length());
- editor.setSelectionEnd(getLength());
}
setSelectedItem(item);
+ // select the completed part
+ JTextComponent editor =
(JTextComponent)comboBox.getEditor().getEditorComponent();
+ editor.setSelectionStart(offs + str.length());
+ editor.setSelectionEnd(getLength());
}
private void setSelectedItem(Object item) {
More information about the josm-dev
mailing list