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
|
@Override
|
||||||
public boolean longPress(Integer index, Entry<PaperCard, Integer> value, float x, float y) {
|
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);
|
onCardLongPress(index, value, x, y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ public class SpellShopManager extends ItemManager<InventoryItem> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean longPress(Integer index, Entry<InventoryItem, Integer> value, float x, float y) {
|
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);
|
toggleMultiSelectMode(index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,36 +200,38 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tap(Integer index, Entry<T, Integer> value, float x, float y, int count) {
|
public boolean tap(Integer index, Entry<T, Integer> value, float x, float y, int count) {
|
||||||
if (maxSelections > 1) {
|
if (maxSelections > 1) { //if multi-select
|
||||||
if (selectedIndices.contains(index)) {
|
//don't toggle checkbox if renderer handles tap
|
||||||
//allow removing selection if it won't fall below min
|
if (!renderer.tap(index, value, x, y, count)) {
|
||||||
//or if max selected (since you need to be able to deselect an item before selecting a new item)
|
if (selectedIndices.contains(index)) {
|
||||||
if (selectedIndices.size() > minSelections || selectedIndices.size() == maxSelections) {
|
//allow removing selection if it won't fall below min
|
||||||
selectedIndices.remove(index);
|
//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();
|
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);
|
setSelectedIndex(index);
|
||||||
}
|
|
||||||
if (renderer.tap(index, value, x, y, count)) {
|
//don't activate if renderer handles tap
|
||||||
prevTapIndex = index;
|
if (!renderer.tap(index, value, x, y, count)) {
|
||||||
return true; //don't activate if renderer handles tap
|
if (count == 1) {
|
||||||
}
|
itemManager.showMenu(false);
|
||||||
if (maxSelections <= 1) {
|
}
|
||||||
if (count == 1) {
|
else if (count == 2 && index == prevTapIndex) {
|
||||||
itemManager.showMenu(false);
|
itemManager.activateSelectedItems();
|
||||||
}
|
}
|
||||||
else if (count == 2 && index == prevTapIndex) {
|
|
||||||
itemManager.activateSelectedItems();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prevTapIndex = index;
|
prevTapIndex = index;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user