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

Gesture Hold

Recognize a long press on a logical clock and suppress it after sufficient movement or early release.

Source repository · Package JSON

Use Gesture Hold

use vendor::gesture_hold::gesture_hold;

Run the example

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

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 = gesture_hold_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 = gesture_hold_step(live, args_at(arguments, i), text_number(input));
            let command = gesture_hold_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = gesture_hold_start();
    state = gesture_hold_step(state, "down", 50.0);
    println!(gesture_hold_command(state));
    state = gesture_hold_step(state, "tick", 49.0);
    println!(gesture_hold_command(state));
    state = gesture_hold_step(state, "tick", 50.0);
    println!(gesture_hold_command(state));
    state = gesture_hold_step(state, "up", 60.0);
    println!(gesture_hold_command(state));
}

Expected output

store_deadline
reject
fire_long_press
release_hold

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse files8f668bda56d7631caf677f3a188fa355c2def03158373c4ecf7c01a24439abbfe5283be0a0
0.1.1Download ZIP · Browse files1704bdb3fc1ab0f2023e78792d9d2aea5787aee7733006263949835fcc24d1e31fcaef4b93
0.1.0Download ZIP · Browse files6349f237843039791ca2e583cd3f6dd48f20e20ef545f5e8e165c667f2942de491fe6a8a82