Setting new items array must reset _selectedItemIndex to -1.

This commit is contained in:
and3md 2017-06-21 17:45:00 +02:00
parent 0cbf746cbc
commit 8edcc9a1e7
1 changed files with 4 additions and 0 deletions

View File

@ -225,6 +225,7 @@ class ComboBox : ComboBoxBase {
}
@property void items(string[] itemResourceIds) {
_selectedItemIndex = -1;
setAdapter(new StringListAdapter(itemResourceIds));
if(itemResourceIds.length > 0) {
selectedItemIndex = 0;
@ -233,6 +234,7 @@ class ComboBox : ComboBoxBase {
}
@property void items(dstring[] items) {
_selectedItemIndex = -1;
setAdapter(new StringListAdapter(items));
if(items.length > 0) {
if (selectedItemIndex == -1 || selectedItemIndex > items.length)
@ -242,6 +244,7 @@ class ComboBox : ComboBoxBase {
}
@property void items(StringListValue[] items) {
_selectedItemIndex = -1;
if (auto a = cast(StringListAdapter)_adapter)
a.items = items;
else
@ -369,6 +372,7 @@ class IconTextComboBox : ComboBoxBase {
}
@property void items(StringListValue[] items) {
_selectedItemIndex = -1;
if (auto a = cast(IconStringListAdapter)_adapter)
a.items = items;
else