From 547d8e8b4b179f3d4cd844ec616cdbd5cfd7e3b5 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 26 Jan 2024 13:40:54 +0100 Subject: [PATCH] Add DragAndDrop::ClearPayload --- crates/egui/src/drag_and_drop.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/egui/src/drag_and_drop.rs b/crates/egui/src/drag_and_drop.rs index 7ce70b416bd..5c5bd496ad8 100644 --- a/crates/egui/src/drag_and_drop.rs +++ b/crates/egui/src/drag_and_drop.rs @@ -50,6 +50,14 @@ impl DragAndDrop { }); } + /// Clears the payload, setting it to `None`. + pub fn clear_poayload(ctx: &Context) { + ctx.data_mut(|data| { + let state = data.get_temp_mut_or_default::(Id::NULL); + state.payload = None; + }); + } + /// Retrieve the payload, if any. /// /// Returns `None` if there is no payload, or if it is not of the requested type.