From 8128bca0215884abad9d2b8bcd1d2b64c81dcb10 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 3 Nov 2024 18:48:15 -0600 Subject: [PATCH] vxfw(SplitView): reset state on mouse_leave --- src/vxfw/SplitView.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vxfw/SplitView.zig b/src/vxfw/SplitView.zig index 9030657..8c19a9a 100644 --- a/src/vxfw/SplitView.zig +++ b/src/vxfw/SplitView.zig @@ -35,7 +35,14 @@ pub fn widget(self: *const SplitView) vxfw.Widget { fn typeErasedEventHandler(ptr: *anyopaque, ctx: *vxfw.EventContext, event: vxfw.Event) anyerror!void { const self: *SplitView = @ptrCast(@alignCast(ptr)); - if (event != .mouse) return; + switch (event) { + .mouse_leave => { + self.pressed = false; + return; + }, + .mouse => {}, + else => return, + } const mouse = event.mouse; const separator_col: u16 = switch (self.constrain) { @@ -71,6 +78,7 @@ fn typeErasedEventHandler(ptr: *anyopaque, ctx: *vxfw.EventContext, event: vxfw. if (self.max_width) |max| { self.width = @min(self.width, max); } + ctx.consume_event = true; } }