Skip to content

Commit

Permalink
Check for item "held" via touch instead of touch event
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Dec 2, 2023
1 parent e7ed2e0 commit f598d47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions srcjs/stendhal/ui/ViewPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ export class ViewPort {
// item was dropped
stendhal.ui.heldItem = undefined;

const is_touch = window['TouchEvent'] && e instanceof TouchEvent;
// if ctrl is pressed or is a touch event, we ask for the quantity
if (e.ctrlKey || is_touch) {
ui.createSingletonFloatingWindow("Quantity", new DropQuantitySelectorDialog(action, is_touch), pos.pageX - 50, pos.pageY - 25);
const touch_held = typeof(stendhal.ui.touch.held) !== "undefined";
// if ctrl is pressed or holding item from touch event, we ask for the quantity
if (e.ctrlKey || touch_held) {
ui.createSingletonFloatingWindow("Quantity", new DropQuantitySelectorDialog(action, touch_held), pos.pageX - 50, pos.pageY - 25);
} else {
marauroa.clientFramework.sendAction(action);
}
Expand Down
9 changes: 4 additions & 5 deletions srcjs/stendhal/ui/component/ItemContainerImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,13 @@ export class ItemContainerImplementation {

stendhal.ui.heldItem = undefined;

// if ctrl is pressed or using touch, we ask for the quantity
const is_touch = window["TouchEvent"] && event instanceof TouchEvent;
const split_action = (event instanceof DragEvent && event.ctrlKey)
|| is_touch;
// if ctrl is pressed or holding item from touch event, we ask for the quantity
const touch_held = typeof(stendhal.ui.touch.held) !== "undefined";
const split_action = (event instanceof DragEvent && event.ctrlKey) || touch_held;
if (split_action) {
const pos = stendhal.ui.html.extractPosition(event);
ui.createSingletonFloatingWindow("Quantity",
new DropQuantitySelectorDialog(action, is_touch),
new DropQuantitySelectorDialog(action, touch_held),
pos.pageX - 50, pos.pageY - 25);
} else {
marauroa.clientFramework.sendAction(action);
Expand Down

0 comments on commit f598d47

Please sign in to comment.