pub struct DragAndDrop { /* private fields */ }Expand description
Plugin for tracking drag-and-drop payload.
This plugin stores the current drag-and-drop payload internally and handles automatic cleanup when the drag operation ends (via Escape key or mouse release).
This is a low-level API. For a higher-level API, see:
crate::Ui::dnd_drag_sourcecrate::Ui::dnd_drop_zonecrate::Response::dnd_set_drag_payloadcrate::Response::dnd_hover_payloadcrate::Response::dnd_release_payload
This is a built-in plugin in egui, automatically registered during Context creation.
See this example.
Implementations§
Source§impl DragAndDrop
impl DragAndDrop
Sourcepub fn set_payload<Payload>(ctx: &Context, payload: Payload)
pub fn set_payload<Payload>(ctx: &Context, payload: Payload)
Set a drag-and-drop payload.
This can be read by Self::payload until the pointer is released.
Sourcepub fn clear_payload(ctx: &Context)
pub fn clear_payload(ctx: &Context)
Clears the payload, setting it to None.
Sourcepub fn payload<Payload>(ctx: &Context) -> Option<Arc<Payload>>
pub fn payload<Payload>(ctx: &Context) -> Option<Arc<Payload>>
Retrieve the payload, if any.
Returns None if there is no payload, or if it is not of the requested type.
Returns Some both during a drag and on the frame the pointer is released
(if there is a payload).
Sourcepub fn take_payload<Payload>(ctx: &Context) -> Option<Arc<Payload>>
pub fn take_payload<Payload>(ctx: &Context) -> Option<Arc<Payload>>
Retrieve and clear the payload, if any.
Returns None if there is no payload, or if it is not of the requested type.
Returns Some both during a drag and on the frame the pointer is released
(if there is a payload).
Sourcepub fn has_payload_of_type<Payload>(ctx: &Context) -> bool
pub fn has_payload_of_type<Payload>(ctx: &Context) -> bool
Are we carrying a payload of the given type?
Returns true both during a drag and on the frame the pointer is released
(if there is a payload).
Sourcepub fn has_any_payload(ctx: &Context) -> bool
pub fn has_any_payload(ctx: &Context) -> bool
Are we carrying a payload?
Returns true both during a drag and on the frame the pointer is released
(if there is a payload).
Trait Implementations§
Source§impl Clone for DragAndDrop
impl Clone for DragAndDrop
Source§fn clone(&self) -> DragAndDrop
fn clone(&self) -> DragAndDrop
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for DragAndDrop
impl Default for DragAndDrop
Source§fn default() -> DragAndDrop
fn default() -> DragAndDrop
Source§impl Plugin for DragAndDrop
impl Plugin for DragAndDrop
Source§fn on_begin_pass(&mut self, ctx: &Context)
fn on_begin_pass(&mut self, ctx: &Context)
Interrupt drag-and-drop if the user presses the escape key.
This needs to happen at frame start so we can properly capture the escape key.
Source§fn on_end_pass(&mut self, ctx: &Context)
fn on_end_pass(&mut self, ctx: &Context)
Interrupt drag-and-drop if the user releases the mouse button.
This is a catch-all safety net in case user code doesn’t capture the drag payload itself. This must happen at end-of-frame such that we don’t shadow the mouse release event from user code.
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Source§fn input_hook(&mut self, input: &mut RawInput)
fn input_hook(&mut self, input: &mut RawInput)
Source§fn output_hook(&mut self, output: &mut FullOutput)
fn output_hook(&mut self, output: &mut FullOutput)
Auto Trait Implementations§
impl Freeze for DragAndDrop
impl !RefUnwindSafe for DragAndDrop
impl Send for DragAndDrop
impl Sync for DragAndDrop
impl Unpin for DragAndDrop
impl !UnwindSafe for DragAndDrop
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more