Skip to content

Conversation

@apekros
Copy link
Contributor

@apekros apekros commented Dec 21, 2025

Objective

Fixes #21894

Solution

As suggested in the issue adds the drag drop example from #21849 to the picking examples.

Testing

Change is trivial, adding an example so simply ran, and checked it matched the expected behaviour

Showcase

image

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

Copy link

@Hilpogar Hilpogar left a comment

Choose a reason for hiding this comment

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

I think the example isn't very intuitive for someone discovering it for the first time. Replacing the red dot with a box containing "Drag from me" and adding a text in the green arena with "Drop here" could improve the example while keeping the code minimalist.

@apekros apekros force-pushed the apekros/dragdrop_picking branch from 2368dc8 to 1da3114 Compare December 22, 2025 03:22
@apekros
Copy link
Contributor Author

apekros commented Dec 22, 2025

I think the example isn't very intuitive for someone discovering it for the first time. Replacing the red dot with a box containing "Drag from me" and adding a text in the green arena with "Drop here" could improve the example while keeping the code minimalist.

Done! Added screenshot to PR desc

@apekros apekros requested a review from Hilpogar December 22, 2025 03:27
Copy link

@Hilpogar Hilpogar left a comment

Choose a reason for hiding this comment

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

Perfect 👍

@ickshonpe ickshonpe added C-Examples An addition or correction to our examples A-UI Graphical user interfaces, styles, layouts, and widgets A-Picking Pointing at and selecting objects of all sorts S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 22, 2025
Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

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

Just got a few minor suggestions, but otherwise looks good.

Comment on lines +88 to +98
))
.observe(on_drag_enter)
.observe(on_drag_over)
.observe(on_drag_drop)
.observe(on_drag_leave);

commands.spawn((
Text2d::new("Drop here"),
TextColor(Color::WHITE),
Pickable::IGNORE,
));
Copy link
Contributor

@ickshonpe ickshonpe Dec 22, 2025

Choose a reason for hiding this comment

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

I think it's more natural for the label to be a child of the DropArea entity, and the z-ordering of elements here isn't guaranteed even though in practice it normally renders in the order the entities were spawned.

Suggested change
))
.observe(on_drag_enter)
.observe(on_drag_over)
.observe(on_drag_drop)
.observe(on_drag_leave);
commands.spawn((
Text2d::new("Drop here"),
TextColor(Color::WHITE),
Pickable::IGNORE,
));
children![(
Text2d::new("Drop here"),
TextFont::from_font_size(50.),
TextColor(Color::BLACK),
Pickable::IGNORE,
Transform::from_translation(Vec3::Z),
)],
))
.observe(on_drag_enter)
.observe(on_drag_over)
.observe(on_drag_drop)
.observe(on_drag_leave);

GhostPreview,
Mesh2d(meshes.add(Circle::new(ELEMENT_SIZE))),
MeshMaterial2d(materials.add(Color::srgba(1.0, 1.0, 0.6, 0.5))),
Transform::from_translation(position),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Transform::from_translation(position),
Transform::from_translation(position + 2. * Vec3::Z),

DroppedElement,
Mesh2d(meshes.add(Circle::new(ELEMENT_SIZE))),
MeshMaterial2d(materials.add(Color::srgb(1.0, 1.0, 0.6))),
Transform::from_translation(position),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Transform::from_translation(position),
Transform::from_translation(position + 2. * Vec3::Z),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Picking Pointing at and selecting objects of all sorts A-UI Graphical user interfaces, styles, layouts, and widgets C-Examples An addition or correction to our examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add drag and drop example to picking examples

3 participants