diff --git a/src/ui/left_panel.zig b/src/ui/left_panel.zig index f941b31..9e72314 100644 --- a/src/ui/left_panel.zig +++ b/src/ui/left_panel.zig @@ -51,7 +51,7 @@ fn objectTreeRow(open_doc: *WindowContext.OpenDocument, obj: *Object, depth: u32 .mouse => |*mouse| { if (!dvui.eventMatchSimple(e, row_data)) continue; hovered = true; - if (mouse.action == .press and mouse.button == .left) { + if (mouse.action == .release and mouse.button == .left) { select_row = true; } }, @@ -84,6 +84,7 @@ fn objectTreeRow(open_doc: *WindowContext.OpenDocument, obj: *Object, depth: u32 }; if (dvui.buttonIcon(@src(), "Delete object", icons.trash, .{}, .{}, delete_opts)) { object_callback.* = .{ .delete = obj.id }; + select_row = false; } } } @@ -122,7 +123,8 @@ fn objectTree(ctx: *WindowContext) void { }, .delete => |obj_id| { _ = doc.removeObjectById(obj_id); - open_doc.selected_object_id = null; + if (open_doc.selected_object_id == obj_id) + open_doc.selected_object_id = null; open_doc.canvas.requestRedraw(); }, } diff --git a/src/ui/tab_bar.zig b/src/ui/tab_bar.zig index 9d45bf4..2beba73 100644 --- a/src/ui/tab_bar.zig +++ b/src/ui/tab_bar.zig @@ -34,7 +34,7 @@ fn documentTab(ctx: *WindowContext, index: usize, callback: *?DocCallback) void .mouse => |*mouse| { if (!dvui.eventMatchSimple(e, row_data)) continue; hovered = true; - if (mouse.action == .press and mouse.button == .left) { + if (mouse.action == .release and mouse.button == .left) { select_row = true; } }, @@ -67,6 +67,7 @@ fn documentTab(ctx: *WindowContext, index: usize, callback: *?DocCallback) void .gravity_y = 0.5, })) { callback.* = .{ .close = index }; + select_row = false; } } }