X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTComboBox.java;h=1ef6bcd4ffd8ecd3a518646f7095412236e4d629;hb=9d990083da421ec7151d7462afa96305273af483;hp=bb223c3a12aa4b6b3340bdaf544858a6025fde25;hpb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;p=fanfix.git diff --git a/src/jexer/TComboBox.java b/src/jexer/TComboBox.java index bb223c3..1ef6bcd 100644 --- a/src/jexer/TComboBox.java +++ b/src/jexer/TComboBox.java @@ -96,13 +96,12 @@ public class TComboBox extends TWidget { this.updateAction = updateAction; - field = new TField(this, 0, 0, width - 3, false, "", - updateAction, null); + field = addField(0, 0, width - 3, false, "", updateAction, null); if (valuesIndex >= 0) { field.setText(values.get(valuesIndex)); } - list = new TList(this, values, 0, 1, width, valuesHeight, + list = addList(values, 0, 1, width, valuesHeight, new TAction() { public void DO() { field.setText(list.getSelected()); @@ -249,7 +248,7 @@ public class TComboBox extends TWidget { } } - if (isAbsoluteActive() && (limitToListValue == false)) { + if (isAbsoluteActive()) { comboBoxColor = getTheme().getColor("tcombobox.active"); } else { comboBoxColor = getTheme().getColor("tcombobox.inactive"); @@ -282,11 +281,29 @@ public class TComboBox extends TWidget { * @param text the new text in the edit field */ public void setText(final String text) { + setText(text, true); + } + + /** + * Set combobox text value. + * + * @param text the new text in the edit field + * @param caseSensitive if true, perform a case-sensitive search for the + * list item + */ + public void setText(final String text, final boolean caseSensitive) { field.setText(text); for (int i = 0; i < list.getMaxSelectedIndex(); i++) { - if (list.getSelected().equals(text)) { - list.setSelectedIndex(i); - return; + if (caseSensitive == true) { + if (list.getListItem(i).equals(text)) { + list.setSelectedIndex(i); + return; + } + } else { + if (list.getListItem(i).toLowerCase().equals(text.toLowerCase())) { + list.setSelectedIndex(i); + return; + } } } list.setSelectedIndex(-1);