Count clicks ourselves so double-clicks work at all
Pixi only fills `detail` on the `click` event it synthesises; on `pointerdown` it is always 0, so every `e.detail === 2` branch was dead code. Asset rows, hierarchy folding and select-all in text fields never responded to a double-click. A shared click counter in src/ui/clicks.ts replaces the three readings of `e.detail`. A finished double-click ends the run, so two in a row count 2 and 2 rather than 3 and 4. The harness could only send `clickCount: 1`, which is why no test caught this: every "activate" check went through Enter. It can send real double-clicks now, and five checks drive the three paths separately.
This commit is contained in:
1 parent
d7c8d3e579
commit
ed1fe31c77
11 files changed
+196
-5
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { type FederatedPointerEvent, Graphics, Text } from 'pixi.js';
|
||||
import { pressCount } from '../clicks';
|
||||
import { centreY } from '../math';
|
||||
import { Theme, textStyle } from '../Theme';
|
||||
import { type Size, Widget } from '../Widget';
|
||||
@@ -223,7 +224,7 @@ export class ListView extends Widget {
|
||||
// being dragged into.
|
||||
if (!this.onDragOut && (!this.highlighted.has(item.id) || item.id === this.selectedId))
|
||||
this.select(item.id);
|
||||
if (e.detail === 2) this.onActivate?.(item.id);
|
||||
if (pressCount(e, item.id) === 2) this.onActivate?.(item.id);
|
||||
else if (this.onDrop || this.onDragOut) {
|
||||
this.drag = { id: item.id, startX: e.global.x, startY: e.global.y, active: false, spot: null };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CanvasTextMetrics, type FederatedPointerEvent, Graphics, Text } from 'pixi.js';
|
||||
import { pressCount } from '../clicks';
|
||||
import { drawControlBox } from '../draw';
|
||||
import type { TextEditTarget } from '../KeyboardBridge';
|
||||
import { centreY, clamp } from '../math';
|
||||
@@ -101,11 +102,12 @@ export class TextField extends Widget implements TextEditTarget {
|
||||
if (e.button !== 0) return;
|
||||
e.stopPropagation();
|
||||
const index = this.indexAt(this.toLocal(e.global).x);
|
||||
const presses = pressCount(e, this);
|
||||
if (!this.editing) {
|
||||
ui().focus.focus(this);
|
||||
if (e.detail >= 2) this.selectAll();
|
||||
if (presses >= 2) this.selectAll();
|
||||
else this.setSelection(index, index, true);
|
||||
} else if (e.detail >= 2) {
|
||||
} else if (presses >= 2) {
|
||||
this.selectAll();
|
||||
} else {
|
||||
this.setSelection(index, index, true);
|
||||
|
||||
Reference in new issue
Block a user