Skip to main content

EventCx

Struct EventCx 

Source
pub struct EventCx<'a> { /* private fields */ }
Expand description

事件上下文——组件通过它标记 dirty、退出应用等

每个 Node 拥有独立的 EventCx,dirty 标记精确到当前节点, 同时通过 global_dirty 确保 Runtime 感知到变更。

Implementations§

Source§

impl<'a> EventCx<'a>

Source

pub fn phase(&self) -> EventPhase

当前事件传播阶段

Source

pub fn stop_propagation(&mut self)

停止事件传播(后续阶段和祖先不再收到该事件)

Source

pub fn invalidate_paint(&mut self)

标记当前节点需要重绘

Source

pub fn invalidate_layout(&mut self)

标记当前节点需要重新布局并重绘

Source

pub fn invalidate(&mut self)

标记需要重新布局(等同于 invalidate_layout)

Source

pub fn invalidate_tree(&mut self)

标记组件树结构变化,触发完整 rebuild + relayout + repaint

Source

pub fn copy_to_clipboard(&self, text: &str)

Copy text to the system clipboard via OSC 52.

Most modern terminals support this. The escape sequence is written directly to stdout.

Source

pub fn quit(&mut self)

退出应用

Source

pub fn dispatch(&mut self, cmd: Command)

发送命令给 Runtime 统一处理(通过全局队列)

Source

pub fn toggle_debug()

切换 debug 视图

Source

pub fn spawn<F>(&mut self, task: F)
where F: FnOnce() -> String + Send + 'static,

启动后台任务

Auto Trait Implementations§

§

impl<'a> Freeze for EventCx<'a>

§

impl<'a> RefUnwindSafe for EventCx<'a>

§

impl<'a> Send for EventCx<'a>

§

impl<'a> Sync for EventCx<'a>

§

impl<'a> Unpin for EventCx<'a>

§

impl<'a> UnsafeUnpin for EventCx<'a>

§

impl<'a> !UnwindSafe for EventCx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.