Skip to main content

WidgetOpened

Struct WidgetOpened 

Source
pub struct WidgetOpened<W>(/* private fields */);
Expand description

Hookable: Triggers when a Widget is created.

§Arguments

§Aliases

Since every Widget implements the HookAlias trait, instead of writing this in the config crate:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<WidgetOpened<LineNumbers>>(|pa, ln| ln.write(pa).relative = true);
}

You can just write this:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<WidgetOpened<LineNumbers>>(|pa, ln| ln.write(pa).relative = true);
}

§Changing the layout

Assuming you are using duat-term, you could make it so every LineNumbers comes with a VertRule on the right, like this:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<WidgetOpened<LineNumbers>>(|pa, handle| {
        VertRule::builder().on_the_right().push_on(pa, handle);
    });
}

Now, every time a LineNumberss Widget is inserted in Duat, a VertRule will be pushed on the right of it. You could even further add a hook on VertRule, that would push further Widgets if you wanted to.

Trait Implementations§

Source§

impl<W: 'static> Hookable for WidgetOpened<W>

Source§

type Input<'h> = &'h Handle<W>

The arguments that are passed to each hook.
Source§

fn get_input<'h>(&'h mut self, _: &mut Pass) -> Self::Input<'h>

How to get the arguments from the Hookable. Read more

Auto Trait Implementations§

§

impl<W> Freeze for WidgetOpened<W>

§

impl<W> !RefUnwindSafe for WidgetOpened<W>

§

impl<W> Send for WidgetOpened<W>

§

impl<W> Sync for WidgetOpened<W>

§

impl<W> Unpin for WidgetOpened<W>

§

impl<W> UnsafeUnpin for WidgetOpened<W>

§

impl<W> !UnwindSafe for WidgetOpened<W>

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.