fix(ios): deliver canvas finger-drag (on_drag) — parity with Android#47
Merged
Conversation
SwiftUI MobCanvasView rendered draw ops but attached no drag recognizer, so a canvas's on_drag handle (wired through the NIF to node.onDrag) was never invoked — continuous finger-drag was dead on iOS while Android's MobCanvas had detectDragGestures. Add a canvas-scoped DragGesture(minimumDistance: 0) that calls node.onDrag with began/dragging/ended phases. The Canvas frame is sized to the declared logical units and draw ops use that same space, so the gesture's local-space location is already in canvas coordinates — no pixel→logical rescale (unlike Android). Verified on a physical iPhone (iOS 26.5): a finger-drawing screen with a color picker and thickness control routes drags and renders strokes correctly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nce, test on_drag wiring Review follow-ups on the canvas on_drag fix (#47): - Flip the dragging @State flag only on the first sample, so a fast drag does not invalidate MobCanvasView on every move. - Document that minimumDistance: 0 is a deliberate divergence from Android's touch-slop (a stationary tap registers as a dot on iOS). - Add renderer_test coverage for on_drag handle wiring, which was untested and is the prop the Swift gesture depends on. The drag-event/phase passthrough is already covered by event/integration_test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GenericJam
added a commit
that referenced
this pull request
Jun 21, 2026
Delivers continuous finger-drag (on_drag) on the iOS Canvas, at parity with Android, plus the review-follow-up polish and on_drag renderer test coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS, a
Canvas'son_draghandle did nothing. The NIF wiresprops["on_drag"]to
node.onDrag(mob_nif.m), but the SwiftUIMobCanvasViewrendered the drawops and attached no drag recognizer, so
node.onDragwas never invoked. Theonly gesture wiring (
mobGestures) covers long-press / double-tap / swipe — notcontinuous drag. Net result: finger-drawing worked on Android (
MobCanvashaddetectDragGestures) but was dead on iOS.This surfaced building a finger-drawing screen: drags onto the canvas produced
nothing on iOS.
Fix
Add a canvas-scoped
DragGesture(minimumDistance: 0)toMobCanvasViewthatcalls
node.onDrag(dx, dy, x, y, phase)withbegan/dragging/endedphases (a
@Stateflag distinguishes the first sample). The Canvas frame issized to the declared logical units (
canvasWidth/canvasHeight) and draw opsare drawn in that same space, so the gesture's
.locallocation is already incanvas coordinates — no pixel→logical rescale is needed (unlike Android,
where Compose hands back pixels). Only attached when
node.onDrag != nil, sonon-interactive canvases are unaffected.
Verification
Verified on a physical iPhone (iOS 26.5) via a Sloppy Joe finger-drawing
screen — a canvas plus a color picker and thickness control:
node.onDrag→mob_send_drag→{:drag, tag, %{x, y, dx, dy, phase}}and render strokes live;Pairs with the Android side, which already had this via
detectDragGestures.Docs
CHANGELOG.md[Unreleased] → Fixed.🤖 Generated with Claude Code