mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Fix so programatically selecting an item in collapsed group auto-expands group
This commit is contained in:
@@ -387,9 +387,17 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
|
||||
@Override
|
||||
public int getIndexOfItem(T item) {
|
||||
for (int i = getCount() - 1; i >= 0; i--) {
|
||||
if (orderedItems.get(i).item == item) {
|
||||
return i;
|
||||
for (Group group : groups) {
|
||||
for (ItemInfo itemInfo : group.items) {
|
||||
if (itemInfo.item == item) {
|
||||
//if group containing item is collapsed, expand it so the item can be selected and has a valid index
|
||||
if (group.isCollapsed) {
|
||||
group.isCollapsed = false;
|
||||
clearSelection(); //must clear selection since indices and visible items will be changing
|
||||
updateLayout();
|
||||
}
|
||||
return itemInfo.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -156,8 +156,6 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
return setSelectedItems(items, true);
|
||||
}
|
||||
public final boolean setSelectedItems(Iterable<T> items, boolean scrollIntoView) {
|
||||
if (getCount() == 0) { return false; }
|
||||
|
||||
List<Integer> indices = new ArrayList<Integer>();
|
||||
for (T item : items) {
|
||||
int index = getIndexOfItem(item);
|
||||
|
||||
Reference in New Issue
Block a user