Struct egui::drag_and_drop::DragAndDrop
source · pub struct DragAndDrop {
payload: Option<Arc<dyn Any + Send + Sync>>,
}
Expand description
Tracking of drag-and-drop payload.
This is a low-level API.
For a higher-level API, see:
crate::Ui::dnd_drag_source
crate::Ui::dnd_drop_zone
crate::Response::dnd_set_drag_payload
crate::Response::dnd_hover_payload
crate::Response::dnd_release_payload
See this example.
Fields§
§payload: Option<Arc<dyn Any + Send + Sync>>
If set, something is currently being dragged
Implementations§
source§impl DragAndDrop
impl DragAndDrop
pub(crate) fn register(ctx: &Context)
sourcefn begin_pass(ctx: &Context)
fn begin_pass(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.
sourcefn end_pass(ctx: &Context)
fn end_pass(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.
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
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)