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> UnsafeUnpin for WebCanvas<UserEventType>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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