pub fn dnd(ui: &mut Ui, id_source: impl Hash) -> Dnd<'_>
Expand description
Main entry point for the drag and drop functionality. Loads and saves it’s state from egui memory. Use either Dnd::show or Dnd::show_vec to display the drag and drop UI. You can use Dnd::with_mouse_config or Dnd::with_touch_config to configure the drag detection. Example usage:
use std::hash::Hash;
use eframe::egui;
use egui::CentralPanel;
use egui_dnd::dnd;
pub fn main() -> eframe::Result<()> {
let mut items = vec!["alfred", "bernhard", "christian"];
eframe::run_simple_native("DnD Simple Example", Default::default(), move |ctx, _frame| {
CentralPanel::default().show(ctx, |ui| {
dnd(ui, "dnd_example")
.show_vec(&mut items, |ui, item, handle, state| {
handle.ui(ui, |ui| {
ui.label("drag");
});
ui.label(*item);
});
});
})
}