pub struct WidgetCreated<W: Widget>(/* 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::<WidgetCreated<LineNumbers>>(|pa, ln| Ok(ln.write(pa).relative = true));
}You can just write this:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
hook::add::<LineNumbers>(|pa, ln| Ok(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::<LineNumbers>(|pa, handle| {
VertRule::builder().on_the_right().push_on(pa, handle);
Ok(())
});
}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 WidgetCreated<W>
impl<W> !RefUnwindSafe for WidgetCreated<W>
impl<W> Send for WidgetCreated<W>
impl<W> Sync for WidgetCreated<W>
impl<W> Unpin for WidgetCreated<W>
impl<W> !UnwindSafe for WidgetCreated<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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.