diff --git a/src/app/mod.rs b/src/app/mod.rs index 9f7ffaa..d56ed36 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -44,6 +44,8 @@ pub fn app() -> Html { handle_canvas_by_tool! {onmousedown, canvas_ref, shapes, tools, cur_tool}; handle_canvas_by_tool! {onmouseup, canvas_ref, shapes, tools, cur_tool}; handle_canvas_by_tool! {onmousemove, canvas_ref, shapes, tools, cur_tool}; + handle_canvas_by_tool! {onmouseleave, canvas_ref, shapes, tools, cur_tool}; + let onresize = { move_to_current_scope!(canvas_ref, shapes); Callback::from(move |_| { @@ -79,6 +81,7 @@ pub fn app() -> Html { {onmouseup} {onmousemove} {onmousedown} + {onmouseleave} {onresize} /> diff --git a/src/app/tools.rs b/src/app/tools.rs index 27351b7..2eea713 100644 --- a/src/app/tools.rs +++ b/src/app/tools.rs @@ -30,6 +30,14 @@ pub trait Tool { shapes: &mut Vec>, ) { } + fn onmouseleave( + &mut self, + position: (f64, f64), + canvas: HtmlCanvasElement, + shapes: &mut Vec>, + ) { + self.onmouseup(position, canvas, shapes) + } } #[derive(Default)]