-
Notifications
You must be signed in to change notification settings - Fork 249
beatMouseDown/Move/Up events do not fire on touch devices (IContainer mouseDown/Move/Up documented as 'mouse/finger' but only handles mouse events) #2634
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
beatMouseDown, beatMouseMove, and beatMouseUp events do not fire on touch devices. Tapping or dragging on the notation with a finger produces no beat mouse events.
The root cause is in HtmlElementContainer.ts — the mouseDown, mouseMove, and mouseUp event emitters are wired to the DOM mousedown, mousemove, and mouseup events respectively. These are not triggered by touch input. While browsers synthesize a mousedown/mouseup after a tap (~300ms delay), mousemove is never synthesized from touch drag — so beatMouseMove never fires on touch, making drag-based interactions (e.g. loop range selection) impossible on touch devices.
This contradicts the JSDoc on IContainer which documents these events as handling both mouse and finger input:
// IContainer.ts
/** This event occurs when a mouse/finger press happened on the control. */
mouseDown: IEventEmitterOfT<IMouseEventArgs>;
/** This event occurs when a mouse/finger moves on top of the control. */
mouseMove: IEventEmitterOfT<IMouseEventArgs>;
/** This event occurs when a mouse/finger is released from the control. */
mouseUp: IEventEmitterOfT<IMouseEventArgs>;
Expected Behavior
beatMouseDown, beatMouseMove, and beatMouseUp should fire on touch devices, consistent with the "mouse/finger" documentation on IContainer.
Steps To Reproduce
- Open any alphaTab instance on a touch device (iOS Safari or Android Firefox/Chrome)
- Subscribe to beat mouse events:
api.beatMouseDown.on(b => console.log('down', b)) - Tap or drag on the notation with a finger
- Observe: no events fire on touch (only fires after synthetic ~300ms mouse event on tap, never on drag)
Proposed Fix
Replace mousedown/mousemove/mouseup with the Pointer Events API (pointerdown/pointermove/pointerup) in HtmlElementContainer.ts. PointerEvent extends MouseEvent so BrowserMouseEventArgs remains fully compatible with minimal changes.
This fix has been implemented and tested on:
- iPhone (Safari) —
beatMouseDown,beatMouseMove,beatMouseUpall confirmed firing on touch - Lenovo Android tablet (Firefox 149) — all three events confirmed firing on touch
A pull request with the fix is ready.
Version and Environment
[AlphaTab][VersionInfo] alphaTab 1.9.0
[AlphaTab][VersionInfo] commit: f06209edcad55081debea735e6c40b9467467a47
[AlphaTab][VersionInfo] build date: 2026-04-04T00:14:58.116Z
[AlphaTab][VersionInfo] High DPI: 1.5
[AlphaTab][VersionInfo] Browser: Mozilla/5.0 (Android 11; Mobile; rv:149.0) Gecko/149.0 Firefox/149.0
[AlphaTab][VersionInfo] Platform: BrowserModule
[AlphaTab][VersionInfo] WebPack: false
[AlphaTab][VersionInfo] Vite: false
[AlphaTab][VersionInfo] Window Size: 800x1293
[AlphaTab][VersionInfo] Screen Size: 800x1333
Platform
Web
Anything else?
The HtmlElementContainer class is tagged @target web and is hand-written (not transpiled), so this change has zero impact on .NET or Android targets.
The fix is a minimal two-file change:
packages/alphatab/src/platform/javascript/HtmlElementContainer.ts— swapmousedown/mousemove/mouseup→pointerdown/pointermove/pointeruppackages/alphatab/src/platform/javascript/BrowserMouseEventArgs.ts— update type fromMouseEvent→PointerEvent(which extendsMouseEvent, fully backward compatible)