X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTComboBox.java;h=0814177d495d858ee02d6df734336dcd4fe41019;hb=978a5d8f650488c8840d54ccc3032599ca50a084;hp=bb223c3a12aa4b6b3340bdaf544858a6025fde25;hpb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;p=fanfix.git diff --git a/src/jexer/TComboBox.java b/src/jexer/TComboBox.java index bb223c3..0814177 100644 --- a/src/jexer/TComboBox.java +++ b/src/jexer/TComboBox.java @@ -249,7 +249,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 +282,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);