pub struct DndManager { /* private fields */ }Expand description
应用内拖放管理器。
Rc<RefCell<_>> 共享:source widget 持有一份用于 begin,app 持有一份用于
update/finish/cancel。单线程、不读墙钟。
Implementations§
Source§impl DndManager
impl DndManager
pub fn new() -> Self
pub fn session(&self) -> Option<DragSession>
pub fn is_active(&self) -> bool
Sourcepub fn begin(
&self,
source: ElementId,
payload: DragPayload,
position: Point,
) -> bool
pub fn begin( &self, source: ElementId, payload: DragPayload, position: Point, ) -> bool
开启会话。已有活跃会话时拒绝新会话(单指针应用内 DnD 的兜底),
返回 false 表示未开启;终态会话可直接被下一次 begin 覆盖。
Sourcepub fn update(
&self,
tree: &mut ElementTree,
position: Point,
) -> Option<ElementId>
pub fn update( &self, tree: &mut ElementTree, position: Point, ) -> Option<ElementId>
指针移动时由 app 调用:用 tree 命中目标,沿祖先链找最近的 DropTarget。
返回当前 hover 的 target(若有),供 app 决定光标形态/重绘。
Sourcepub fn finish(&self, tree: &mut ElementTree, position: Point) -> bool
pub fn finish(&self, tree: &mut ElementTree, position: Point) -> bool
抬起时由 app 调用:命中目标并尝试 drop。返回是否消费成功。
Sourcepub fn cancel_with_tree(&self, tree: &mut ElementTree)
pub fn cancel_with_tree(&self, tree: &mut ElementTree)
带 tree 的取消:会通知当前 hover 目标 drag_leave。
Sourcepub fn keyboard_pickup(
&self,
tree: &ElementTree,
source: ElementId,
payload: DragPayload,
) -> bool
pub fn keyboard_pickup( &self, tree: &ElementTree, source: ElementId, payload: DragPayload, ) -> bool
键盘等价「拾取」:为指定 source 开会话,位置为 source 的 element 原点。
app 把 KeyDown(Enter/Space) 翻译为本调用;与鼠标 Pan 走同一个会话结构,
因此后续命中/drop/replay 完全一致。
Sourcepub fn keyboard_move(
&self,
tree: &mut ElementTree,
dx: f32,
dy: f32,
) -> Option<ElementId>
pub fn keyboard_move( &self, tree: &mut ElementTree, dx: f32, dy: f32, ) -> Option<ElementId>
键盘等价「移动」:按 logical 像素步进更新指针位置并重新命中目标。
Sourcepub fn keyboard_drop(&self, tree: &mut ElementTree) -> bool
pub fn keyboard_drop(&self, tree: &mut ElementTree) -> bool
键盘等价「放下」:在当前位置完成 drop。
Trait Implementations§
Source§impl Clone for DndManager
impl Clone for DndManager
Source§impl Debug for DndManager
impl Debug for DndManager
Auto Trait Implementations§
impl !RefUnwindSafe for DndManager
impl !Send for DndManager
impl !Sync for DndManager
impl !UnwindSafe for DndManager
impl Forget for DndManager
impl Freeze for DndManagerwhere
*const RcInner<RefCell<Option<DragSession>>> is !null: Freeze,
PhantomData<RcInner<RefCell<Option<DragSession>>>>: Freeze,
impl Move for DndManager
impl Unpin for DndManager
impl UnsafeUnpin for DndManagerwhere
*const RcInner<RefCell<Option<DragSession>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<Option<DragSession>>>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more