Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Drag Capture

Keep pointer capture with its originating pointer during drag, cancel and drop.

Source repository · Package JSON

Use Drag Capture

use vendor::drag_capture::drag_capture;

Run the example

nest demo drag_capture@0.1.2
blyxc native-run drag_capture-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::drag_capture::drag_capture;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = drag_capture_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = drag_capture_step(live, args_at(arguments, i), text_number(input));
            let command = drag_capture_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = drag_capture_start();
    state = drag_capture_step(state, "down", 2.0);
    println!(drag_capture_command(state));
    state = drag_capture_step(state, "move", 3.0);
    println!(drag_capture_command(state));
    state = drag_capture_step(state, "move", 2.0);
    println!(drag_capture_command(state));
    state = drag_capture_step(state, "up", 2.0);
    println!(drag_capture_command(state));
}

Expected output

capture_pointer
reject
preview_position
commit_drop

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse files629d76a96a0254835e45e565af1ad04280106f7d88fea73dd9a50b02a2158bfb0bce65a49d
0.1.1Download ZIP · Browse filesc97f57928c1088fdc0f20b6f4942bd7b5339b09b044d3133730278986c9f9b38c4c20926ee
0.1.0Download ZIP · Browse files6349f23784046eda0b85590f106d61d8e2980e128eeee49ccb17afc5d04f4aaecc71ca1f45