[][src]Struct druid::WidgetId

pub struct WidgetId(_);

A unique identifier for a single Widget.

WidgetIds are generated automatically for all widgets that participate in layout. More specifically, each WidgetPod has a unique WidgetId.

These ids are used internally to route events, and can be used to communicate between widgets, by submitting a command (as with EventCtx::submit_command) and passing a WidgetId as the Target.

A widget can retrieve its id via methods on the various contexts, such as LifeCycleCtx::widget_id.

Explicit WidgetIds.

Sometimes, you may want to know a widget's id when constructing the widget. You can give a widget an explicit id by wrapping it in an IdentityWrapper widget, or by using the WidgetExt::with_id convenience method.

If you set a WidgetId directly, you are resposible for ensuring that it is unique in time. That is: only one widget can exist with a given id at a given time.

Implementations

impl WidgetId[src]

pub fn next() -> WidgetId[src]

Allocate a new, unique WidgetId.

All widgets are assigned ids automatically; you should only create an explicit id if you need to know it ahead of time, for instance if you want two sibling widgets to know each others' ids.

You must ensure that a given WidgetId is only ever used for one widget at a time.

pub const fn reserved(raw: u16) -> WidgetId[src]

Create a reserved WidgetId, suitable for reuse.

The caller is responsible for ensuring that this ID is in fact assigned to a single widget at any time, or your code may become haunted.

The actual inner representation of the returned WidgetId will not be the same as the raw value that is passed in; it will be u64::max_value() - raw.

Trait Implementations

impl Clone for WidgetId[src]

impl Copy for WidgetId[src]

impl Debug for WidgetId[src]

impl Eq for WidgetId[src]

impl From<WidgetId> for Target[src]

impl Hash for WidgetId[src]

impl Into<Option<Target>> for WidgetId[src]

impl PartialEq<WidgetId> for WidgetId[src]

impl StructuralEq for WidgetId[src]

impl StructuralPartialEq for WidgetId[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.