pub struct WebCanvas<UserEventType = ()>where
UserEventType: 'static,{ /* private fields */ }
Expand description
Struct representing an HTML canvas.
Implementations§
Source§impl WebCanvas<()>
impl WebCanvas<()>
Sourcepub fn new_for_id<S, H>(
element_id: S,
handler: H,
) -> Result<WebCanvas<()>, BacktraceError<ErrorMessage>>
pub fn new_for_id<S, H>( element_id: S, handler: H, ) -> Result<WebCanvas<()>, BacktraceError<ErrorMessage>>
Creates (and starts running) a new WebCanvas instance, attached to the HTML canvas with the specified ID. Event handlers will be registered for keyboard, mouse, and other events.
The event loop/handlers will continue to exist after the WebCanvas is dropped. This behaviour can be avoided using WebCanvas::unregister_when_dropped.
The provided WindowHandler will start to receive callbacks as soon as this function returns. Note that the main thread must not be blocked.
Source§impl<UserEventType: 'static> WebCanvas<UserEventType>
impl<UserEventType: 'static> WebCanvas<UserEventType>
Sourcepub fn new_for_id_with_user_events<S, H>(
element_id: S,
handler: H,
) -> Result<Self, BacktraceError<ErrorMessage>>
pub fn new_for_id_with_user_events<S, H>( element_id: S, handler: H, ) -> Result<Self, BacktraceError<ErrorMessage>>
Creates (and starts running) a new WebCanvas instance, attached to the HTML canvas with the specified ID. Event handlers will be registered for keyboard, mouse, and other events.
This variant has support for user-generated events. See window::UserEventSender for more details.
The event loop/handlers will continue to exist after the WebCanvas is dropped. This behaviour can be avoided using WebCanvas::unregister_when_dropped.
The provided WindowHandler will start to receive callbacks as soon as this function returns. Note that the main thread must not be blocked.
Sourcepub fn unregister_when_dropped(&mut self)
pub fn unregister_when_dropped(&mut self)
Causes the WebCanvas event loop to terminate when the WebCanvas is dropped. If this function is not called, then the event loop (and associated event handlers) will continue to run after the WebCanvas struct is dropped.
Trait Implementations§
Auto Trait Implementations§
impl<UserEventType> Freeze for WebCanvas<UserEventType>
impl<UserEventType> RefUnwindSafe for WebCanvas<UserEventType>where
UserEventType: RefUnwindSafe,
impl<UserEventType> Send for WebCanvas<UserEventType>where
UserEventType: Send,
impl<UserEventType> Sync for WebCanvas<UserEventType>where
UserEventType: Sync,
impl<UserEventType> Unpin for WebCanvas<UserEventType>where
UserEventType: Unpin,
impl<UserEventType> UnwindSafe for WebCanvas<UserEventType>where
UserEventType: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more