pub struct WidgetOpened<W>(/* private fields */);Expand description
Hookable: Triggers when a Widget is created.
§Arguments
- The
Handle<W>of saidWidget.
§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§
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> 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