canvas.gui.widgets.ComboBox: Bug fixes, implement findByValue and findByText methods, add placeholders for missing artwork
This commit is contained in:
parent
51e16819be
commit
ad266eb743
4 changed files with 22 additions and 3 deletions
|
@ -54,7 +54,7 @@ gui.widgets.ComboBox = {
|
|||
var index = 0;
|
||||
foreach(var i; me._items) {
|
||||
if (i.menuValue == value) {
|
||||
setCurrentByIndex(index);
|
||||
me.setCurrentByIndex(index);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -68,13 +68,32 @@ gui.widgets.ComboBox = {
|
|||
if (me._currentIndex == index)
|
||||
return;
|
||||
|
||||
if (index >= size(me._items)) {
|
||||
logprint(DEV_WARN, "Canvas.Gui ComboBox: invalid index passed to setCUrrentByIndex" ~ index);
|
||||
if (index >= size(me._items) or index < 0) {
|
||||
logprint(DEV_WARN, "Canvas.Gui ComboBox: invalid index passed to setCurrentByIndex" ~ index);
|
||||
return;
|
||||
}
|
||||
|
||||
me._currentIndex = index;
|
||||
me._view.setText(me, me._items[index].text());
|
||||
me._trigger("selected-item-changed", {"index": index, "text": me._items[index].text(), "value": me._items[index].menuValue});
|
||||
},
|
||||
|
||||
findByValue: func(value) {
|
||||
for (var i = 0; i < size(me._items); i += 1) {
|
||||
if (me._items[i].menuValue == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
findByText: func(text) {
|
||||
for (var i = 0; i < size(me._items); i += 1) {
|
||||
if (me._items[i].text() == text) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
setDown: func(down = 1)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 544 B |
BIN
gui/styles/AmbianceClassic/widgets/backdrop-combobox-button.png
Normal file
BIN
gui/styles/AmbianceClassic/widgets/backdrop-combobox-button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 544 B |
BIN
gui/styles/AmbianceClassic/widgets/backdrop-combobox-entry.png
Normal file
BIN
gui/styles/AmbianceClassic/widgets/backdrop-combobox-entry.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 B |
Loading…
Add table
Reference in a new issue