mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Avoid toggling multi-select mode if long press on card art
Avoid toggling checkbox if user taps on card art
This commit is contained in:
@@ -79,6 +79,9 @@ public class CardManager extends ItemManager<PaperCard> {
|
||||
|
||||
@Override
|
||||
public boolean longPress(Integer index, Entry<PaperCard, Integer> value, float x, float y) {
|
||||
if (CardRenderer.cardListItemTap(model.getOrderedList(), index, CardManager.this, x, y, 1, compactModeHandler.isCompactMode())) {
|
||||
return true; //avoid calling onCardLongPress if user long presses on card art
|
||||
}
|
||||
onCardLongPress(index, value, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ public class SpellShopManager extends ItemManager<InventoryItem> {
|
||||
|
||||
@Override
|
||||
public boolean longPress(Integer index, Entry<InventoryItem, Integer> value, float x, float y) {
|
||||
if (value.getKey() instanceof PaperCard && CardRenderer.cardListItemTap(model.getOrderedList(), index, SpellShopManager.this, x, y, 1, compactModeHandler.isCompactMode())) {
|
||||
return true; //avoid calling toggleMultiSelectMode if user long presses on card art
|
||||
}
|
||||
toggleMultiSelectMode(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,36 +200,38 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
||||
|
||||
@Override
|
||||
public boolean tap(Integer index, Entry<T, Integer> value, float x, float y, int count) {
|
||||
if (maxSelections > 1) {
|
||||
if (selectedIndices.contains(index)) {
|
||||
//allow removing selection if it won't fall below min
|
||||
//or if max selected (since you need to be able to deselect an item before selecting a new item)
|
||||
if (selectedIndices.size() > minSelections || selectedIndices.size() == maxSelections) {
|
||||
selectedIndices.remove(index);
|
||||
if (maxSelections > 1) { //if multi-select
|
||||
//don't toggle checkbox if renderer handles tap
|
||||
if (!renderer.tap(index, value, x, y, count)) {
|
||||
if (selectedIndices.contains(index)) {
|
||||
//allow removing selection if it won't fall below min
|
||||
//or if max selected (since you need to be able to deselect an item before selecting a new item)
|
||||
if (selectedIndices.size() > minSelections || selectedIndices.size() == maxSelections) {
|
||||
selectedIndices.remove(index);
|
||||
onSelectionChange();
|
||||
}
|
||||
}
|
||||
else if (selectedIndices.size() < maxSelections) {
|
||||
selectedIndices.add(index);
|
||||
Collections.sort(selectedIndices); //ensure selected indices are sorted
|
||||
onSelectionChange();
|
||||
}
|
||||
}
|
||||
else if (selectedIndices.size() < maxSelections) {
|
||||
selectedIndices.add(index);
|
||||
Collections.sort(selectedIndices); //ensure selected indices are sorted
|
||||
onSelectionChange();
|
||||
}
|
||||
}
|
||||
else {
|
||||
else { //if single-select
|
||||
setSelectedIndex(index);
|
||||
}
|
||||
if (renderer.tap(index, value, x, y, count)) {
|
||||
prevTapIndex = index;
|
||||
return true; //don't activate if renderer handles tap
|
||||
}
|
||||
if (maxSelections <= 1) {
|
||||
if (count == 1) {
|
||||
itemManager.showMenu(false);
|
||||
}
|
||||
else if (count == 2 && index == prevTapIndex) {
|
||||
itemManager.activateSelectedItems();
|
||||
|
||||
//don't activate if renderer handles tap
|
||||
if (!renderer.tap(index, value, x, y, count)) {
|
||||
if (count == 1) {
|
||||
itemManager.showMenu(false);
|
||||
}
|
||||
else if (count == 2 && index == prevTapIndex) {
|
||||
itemManager.activateSelectedItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prevTapIndex = index;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user