Repository: bevyengine/bevy
File: examples/picking/dragdrop_picking.rs (Rust)

Code before:
                .observe(
                    |mut event: On<Pointer<DragEnd>>,
                     mut button_color: Single<&mut BackgroundColor, With<DraggableButton>>| {
                        button_color.0 = Color::srgb(1.0, 0.0, 0.0);
                        event.propagate(false);
                    },
                );
        });

    commands
        .spawn((
            DropArea,
            Mesh2d(meshes.add(Rectangle::new(AREA_SIZE, AREA_SIZE))),
            MeshMaterial2d(materials.add(Color::srgb(0.1, 0.4, 0.1))),
            Transform::IDENTITY,
        ))
        .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,
    ));
}

fn on_drag_enter(
    mut event: On<Pointer<DragEnter>>,
    button: Single<Entity, With<DraggableButton>>,
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    if event.dragged == *button {
        let Some(position) = event.hit.position else {
            return;
        };
        commands.spawn((
            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),
            Pickable::IGNORE,
        ));
        event.propagate(false);
    }
}

fn on_drag_over(

Review comment (suggestion):
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. 

```suggestion
            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);
```

Code after:
                .observe(
                    |mut event: On<Pointer<DragEnd>>,
                     mut button_color: Single<&mut BackgroundColor, With<DraggableButton>>| {
                        button_color.0 = Color::srgb(1.0, 0.0, 0.0);
                        event.propagate(false);
                    },
                );
        });

    commands
        .spawn((
            DropArea,
            Mesh2d(meshes.add(Rectangle::new(AREA_SIZE, AREA_SIZE))),
            MeshMaterial2d(materials.add(Color::srgb(0.1, 0.4, 0.1))),
            Transform::IDENTITY,
            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);
}

fn on_drag_enter(
    mut event: On<Pointer<DragEnter>>,
    button: Single<Entity, With<DraggableButton>>,
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    if event.dragged == *button {
        let Some(position) = event.hit.position else {
            return;
        };
        commands.spawn((
            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 + 2. * Vec3::Z),
            Pickable::IGNORE,
        ));
        event.propagate(false);
    }
}