Skip to content

Conversation

@cpcallen
Copy link
Collaborator

There was an error in the initial implementation of DragMover (in PR #317), where the drag delta was being passed in workspace coordinates instead of pixels. This lead to various problems, notably #446.

Fixes #446.

@cpcallen cpcallen requested a review from a team as a code owner June 17, 2025 15:11
@cpcallen cpcallen requested review from BenHenning and removed request for a team June 17, 2025 15:11
@cpcallen cpcallen marked this pull request as draft June 17, 2025 15:12
@cpcallen cpcallen force-pushed the fix/446 branch 2 times, most recently from 0607f32 to 6ebb919 Compare June 17, 2025 15:22
@sappm01 sappm01 removed this from Blockly 2025 Jun 17, 2025
cpcallen added 3 commits June 18, 2025 19:14
Change the signature of sendKeyAndWait:

- Export it, so it can be used directly by tests.
- Allow multiple keys to be specified.
- Make times parameter optional (default 1).
@cpcallen cpcallen marked this pull request as ready for review June 18, 2025 18:37
@cpcallen cpcallen moved this to In Progress in Blockly 2025 Jun 18, 2025
Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cpcallen! Seems like a really nice fix. Just had some nits and one core design consideration, but otherwise the PR LGTM.

info.dragger.onDrag(
info.fakePointerEvent('pointermove', direction),
info.totalDelta,
info.totalDelta.clone().scale(workspace.scale),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wonder if we should have distinct types for different coordinate spaces, e.g. ScreenCoordinate and WorkspaceCoordinate. It's not obvious from code that scaling performs the space conversion, or what coordinate system we're currently in at this point (since if totalDelta is already in screen space then scaling again would be wrong).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a great idea; I've filed RaspberryPiFoundation/blockly#9156 for future consideration.

Relatedly, one of the things I somewhat dislike about TypeScript (and also Go) is duck typing: it should be possible to give different names to the same type specification and have the compiler flag any mixed use (absent explicit casts). For object types it's pretty easy to make things different shapes (adding a dummy method to the class definition changes the type without changing the actuals shape of the objects in memory), but a classic use of nominal typing is to distinguish between strings containing HTML and ones containing plain text, and enforce calling a function to do escaping when converting the latter to the former. TypeScript doesn't let you do that—you'd have to use subclasses of the String object type rather than plain strings.

@cpcallen cpcallen merged commit 68c99d1 into RaspberryPiFoundation:main Jun 19, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Blockly 2025 Jun 19, 2025
@cpcallen cpcallen deleted the fix/446 branch July 10, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constrained move after unconstrained move translates the block in MakeCode

2 participants