pub struct WebCanvas<UserEventType = ()> where
UserEventType: 'static, { /* private fields */ }
Expand description
Struct representing an HTML canvas.
Implementations
pub fn new_for_id<S, H>(
element_id: S,
handler: H
) -> Result<WebCanvas<()>, BacktraceError<ErrorMessage>> where
S: AsRef<str>,
H: WindowHandler<()> + 'static,
pub fn new_for_id<S, H>(
element_id: S,
handler: H
) -> Result<WebCanvas<()>, BacktraceError<ErrorMessage>> where
S: AsRef<str>,
H: WindowHandler<()> + 'static,
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.
pub fn new_for_id_with_user_events<S, H>(
element_id: S,
handler: H
) -> Result<Self, BacktraceError<ErrorMessage>> where
S: AsRef<str>,
H: WindowHandler<UserEventType> + 'static,
pub fn new_for_id_with_user_events<S, H>(
element_id: S,
handler: H
) -> Result<Self, BacktraceError<ErrorMessage>> where
S: AsRef<str>,
H: WindowHandler<UserEventType> + 'static,
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.
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.