processEventsBefore
Parameters
- self:*FloatingWindowWidget
- *FloatingWindowWidget
Source
Implementation
pub fn processEventsBefore(self: *FloatingWindowWidget) void {
const rs = self.data().rectScale();
const evts = dvui.events();
for (evts) |*e| {
if (!dvui.eventMatch(e, .{ .id = self.data().id, .r = rs.r }))
continue;
if (e.evt == .mouse) {
const me = e.evt.mouse;
if (me.action == .focus) {
// focus but let the focus event propagate to widgets
dvui.focusSubwindow(self.data().id, e.num);
continue;
}
// If we are already dragging, do it here so it happens before drawing
if (dvui.captured(self.data().id)) {
if (me.action == .motion) {
if (dvui.dragging(me.p, null)) |dps| {
const p = me.p.plus(dvui.dragOffset()).toNatural();
self.dragAdjust(p, dps.toNatural(), self.drag_part.?);
// don't need refresh() because we're before drawing
// but we changed the rect, so need to upate WidgetData's rect_scale
self.wd.rect_scale = self.wd.rectScaleFromParent();
e.handle(@src(), self.data());
continue;
}
}
if (me.action == .release and me.button.pointer()) {
dvui.captureMouse(null, e.num); // stop drag and capture
dvui.dragEnd();
e.handle(@src(), self.data());
continue;
}
}
if (self.init_options.resize == .all and dragPart(me, rs) == .bottom_right) {
if (me.action == .press and me.button.pointer()) {
// capture and start drag
dvui.captureMouse(self.data(), e.num);
self.drag_part = .bottom_right;
dvui.dragStart(me.button, me.p, .{ .cursor = .arrow_nw_se, .offset = .diff(rs.r.bottomRight(), me.p) });
e.handle(@src(), self.data());
continue;
}
if (me.action == .position) {
e.handle(@src(), self.data()); // don't want any widgets under this to see a hover
dvui.cursorSet(.arrow_nw_se);
continue;
}
}
}
}
}