Registry / Framework

framework · v0.1.2
Drag Capture
Keep pointer capture with its originating pointer during drag, cancel and drop.
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
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 629d76a96a | 0254835e45e565af1ad04280106f7d88fea73dd9a50b02a2158bfb0bce65a49d |
| 0.1.1 | Download ZIP · Browse files | c97f57928c | 1088fdc0f20b6f4942bd7b5339b09b044d3133730278986c9f9b38c4c20926ee |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 046eda0b85590f106d61d8e2980e128eeee49ccb17afc5d04f4aaecc71ca1f45 |