Fix notification handling when tool is already selected

This commit is contained in:
Enrico Lumetti 2021-03-10 23:29:03 +01:00
parent 0fdc73b9e4
commit 721ad1eecf
1 changed files with 3 additions and 1 deletions

View File

@ -209,11 +209,14 @@ impl<W: Widget<StilettoState>> Controller<StilettoState, W> for ToolSwitcher {
match event { match event {
Event::Notification(cmd) => { Event::Notification(cmd) => {
let new_tool = if cmd.get(stiletto::commands::PUSH_ERASER).is_some() { let new_tool = if cmd.get(stiletto::commands::PUSH_ERASER).is_some() {
ctx.set_handled();
self.saved_tool = data.current_tool; self.saved_tool = data.current_tool;
Some(data.eraser_tool_id) Some(data.eraser_tool_id)
} else if cmd.get(stiletto::commands::POP_ERASER).is_some() { } else if cmd.get(stiletto::commands::POP_ERASER).is_some() {
ctx.set_handled();
Some(self.saved_tool) Some(self.saved_tool)
} else if cmd.get(stiletto::commands::UPDATE_TOOL).is_some() { } else if cmd.get(stiletto::commands::UPDATE_TOOL).is_some() {
ctx.set_handled();
let old_tool = data.current_tool; let old_tool = data.current_tool;
data.tool_icons data.tool_icons
.iter() .iter()
@ -225,7 +228,6 @@ impl<W: Widget<StilettoState>> Controller<StilettoState, W> for ToolSwitcher {
if let Some(new_tool) = new_tool { if let Some(new_tool) = new_tool {
data.set_tool(new_tool); data.set_tool(new_tool);
ctx.set_handled();
} }
} }
_ => {} _ => {}