[−][src]Struct pushrod::render::callbacks::CallbackRegistry
This is a registry that contains a series of FnMut
definitions for actions that can be applied
to a Widget
. These can vary from a screen refresh (tick
), to a mouse move event, etc. Each
callback gains access to the list of WidgetContainer
objects stored by the cache. This is
important in case you wish to modify other Widget
s on the screen as a result of some action
that took place.
Keep in mind, however, that you cannot re-borrow your own widget from the WidgetContainer
list, as this will cause a runtime exception. For that, use the top-level Widget
object that
was supplied. This will allow you to make changes to the current Widget
reference, since it
is an active, mutable
reference.
Fields
on_tick: FunctionNoParametersType
This is the function that is set when a screen refresh cycle occurs. This function is always guaranteed to be called, but there is no guarantee it will call it consistently because of the screen refresh rate. If there is a lot of activity on the screen, this callback will be called less often.
on_mouse_entered: FunctionNoParametersType
This function is called when a mouse enters the scope of a Widget
.
on_mouse_exited: FunctionNoParametersType
This function is called when a mouse exits the scope of a Widget
.
on_mouse_moved: FunctionPointParametersType
This function is called when a mouse moves inside the scope of a Widget
. It contains
the points as a Vec<i32>
containing the X and Y coordinates of the position of the mouse
inside the Widget
.
on_mouse_scrolled: FunctionPointParametersType
This function is called when a mouse scroll occurs inside the scope of a Widget
. It
contains the points as a Vec<u8>
indicating the amount of movement either horizontally or
vertically.
on_mouse_clicked: FunctionClickParametersType
This function is called when a mouse button is pressed or released. It contains the mouse
button number, the number of clicks registered, and a boolean flag indicating whether or not
the mouse button was pressed (true
) or released (false
).
Methods
impl CallbackRegistry
[src]
Implementation of the CallbackRegistry
.
pub fn new() -> Self
[src]
Creates a new instance of this object.
pub fn on_tick<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
Assigns an FnMut
that will be called when a screen tick
refresh is performed. If this
is not set, this function will be bypassed.
pub fn on_mouse_entered<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
Assigns an FnMut
that will be called when the mouse enters the scope of a Widget
. If this
is not set, this function will be bypassed.
pub fn on_mouse_exited<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer]) + 'static,
Assigns an FnMut
that will be called when the mouse exits the scope of a Widget
. If this
is not set, this function will be bypassed.
pub fn on_mouse_moved<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], Vec<i32>) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], Vec<i32>) + 'static,
Assigns an FnMut
that will be called when the mouse moves within the scope of a Widget
. If this
is not set, this function will be bypassed.
pub fn on_mouse_scrolled<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], Vec<i32>) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], Vec<i32>) + 'static,
Assigns an FnMut
that will be called when the mouse scroll occurs within the scope of a
Widget
. If this is not set, this function will be bypassed.
pub fn on_mouse_clicked<F>(&mut self, callback: F) where
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], u8, u8, bool) + 'static,
[src]
F: FnMut(&mut dyn Widget, &[WidgetContainer], &[LayoutContainer], u8, u8, bool) + 'static,
Assigns an FnMut
that will be called when the mouse click occurs within the scope of a
Widget
. If this is not set, this function will be bypassed.
pub fn has_on_tick(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_tick
callback has been set.
pub fn has_on_mouse_entered(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_mouse_entered
callback has been set.
pub fn has_on_mouse_exited(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_mouse_exited
callback has been set.
pub fn has_on_mouse_moved(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_mouse_moved
callback has been set.
pub fn has_on_mouse_scrolled(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_mouse_scrolled
callback has been set.
pub fn has_on_mouse_clicked(&mut self) -> bool
[src]
Tells the Widget
whether or not an on_mouse_clicked
callback has been set.
Trait Implementations
impl Default for CallbackRegistry
[src]
fn default() -> CallbackRegistry
[src]
Auto Trait Implementations
impl !RefUnwindSafe for CallbackRegistry
impl !Send for CallbackRegistry
impl !Sync for CallbackRegistry
impl Unpin for CallbackRegistry
impl !UnwindSafe for CallbackRegistry
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,