vxfw(SplitView): reset state on mouse_leave

This commit is contained in:
Tim Culverhouse 2024-11-03 18:48:15 -06:00
parent b9fb06d902
commit 8128bca021

View file

@ -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;
}
}