DVUI

processEvent

Parameters

#
self:*ReorderWidget
*ReorderWidget
e:*dvui.Event
*dvui.Event

Source

Implementation

#
pub fn processEvent(self: *ReorderWidget, e: *dvui.Event) void {
    switch (e.evt) {
        .mouse => |me| {
            // if we are the drag source, update where the mouse is and possibly scroll
            if (self.drag_point != null and me.action == .motion) {
                self.drag_point = e.evt.mouse.p;

                dvui.scrollDrag(.{
                    .mouse_pt = e.evt.mouse.p,
                    .screen_rect = self.wd.rectScale().r,
                });
            }

            // detect a drag end that is over us
            // if nobody catches it, dvui.Window will end the drag on an unhandled mouse up
            if (self.dragging() and self.data().borderRectScale().r.contains(dvui.currentWindow().mouse_pt)) {
                if (me.action == .release and me.button.pointer()) {
                    e.handle(@src(), self.data());
                    self.drag_ending = true;
                    dvui.captureMouse(null, e.num);
                    dvui.dragEnd();
                }
            }
        },
        else => {},
    }
}