DVUI

captureMouseMaintain

If the widget ID passed has mouse capture, this maintains that capture for the next frame. This is usually called for you in WidgetData.init.

This can be called every frame regardless of capture.

Only valid between Window.beginand Window.end.

Parameters

#
cm:CaptureMouse
CaptureMouse

Source

Implementation

#
pub fn captureMouseMaintain(cm: CaptureMouse) void {
    const cw = currentWindow();
    if (cw.capture != null and cw.capture.?.id == cm.id) {
        // to maintain capture, we must be on or above the
        // top modal window
        var i = cw.subwindows.stack.items.len;
        while (i > 0) : (i -= 1) {
            const sw = &cw.subwindows.stack.items[i - 1];
            if (sw.id == cw.subwindows.current_id) {
                // maintaining capture
                // either our floating window is above the top modal
                // or there are no floating modal windows
                cw.capture.?.rect = cm.rect;
                cw.captured_last_frame = true;
                return;
            } else if (sw.modal) {
                // found modal before we found current
                // cancel the capture, and cancel
                // any drag being done
                //
                // mark all events as not captured, we are being interrupted by
                // a modal dialog anyway
                captureMouse(null, 0);
                dragEnd();
                return;
            }
        }
    }
}