Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 25, 2024
1 parent faeb1eb commit 5123501
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/egui/src/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use std::{any::Any, sync::Arc};
use crate::{Context, CursorIcon, Id};

/// Helpers for drag-and-drop in egui.
///
/// See [this example](https://github.com/emilk/egui/blob/master/crates/egui_demo_lib/src/demo/drag_and_drop.rs).
#[doc(alias = "drag and drop")]
#[derive(Clone, Default)]
pub struct DragAndDrop {
/// If set, something is currently being dragged
Expand Down
3 changes: 3 additions & 0 deletions crates/egui/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ impl Response {
}

/// If the user started dragging this widget this frame, store the payload for drag-and-drop.
#[doc(alias = "drag and drop")]
pub fn dnd_set_drag_payload<T: Any + Send + Sync>(&self, payload: T) {
if self.drag_started() {
crate::DragAndDrop::set_payload(&self.ctx, payload);
Expand All @@ -344,6 +345,7 @@ impl Response {
///
/// Only returns something if [`Self::contains_pointer`] is true,
/// and the user is drag-dropping something of this type.
#[doc(alias = "drag and drop")]
pub fn dnd_hover_payload<T: Any + Send + Sync>(&self) -> Option<Arc<T>> {
// NOTE: we use `response.contains_pointer` here instead of `hovered`, because
// `hovered` is always false when another widget is being dragged.
Expand All @@ -358,6 +360,7 @@ impl Response {
/// Only returns something if [`Self::contains_pointer`] is true,
/// the user is drag-dropping something of this type,
/// and they released it this frame
#[doc(alias = "drag and drop")]
pub fn dnd_release_payload<T: Any + Send + Sync>(&self) -> Option<Arc<T>> {
// NOTE: we use `response.contains_pointer` here instead of `hovered`, because
// `hovered` is always false when another widget is being dragged.
Expand Down
1 change: 1 addition & 0 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@ impl Ui {
///
/// In contrast to [`Response::dnd_set_drag_payload`],
/// this function will paint the widget at the mouse cursor while the user is dragging.
#[doc(alias = "drag and drop")]
pub fn dnd_drag_source<T, R>(
&mut self,
id: Id,
Expand Down

0 comments on commit 5123501

Please sign in to comment.