Skip to main content

key_value

Function key_value 

Source
pub fn key_value(
    key: &Key,
    shift: bool,
    bar: KeyContext,
) -> Option<(f64, Option<f64>)>
Expand description

The value a key asks for, and the size to remember for Enter, or None for keys the splitter leaves alone. Arrows move the bar, not the value: whether that grows the pane depends on which side of the bar it is on, and in RTL Right is the inline start.

use dioxus::prelude::Key;
use fc_dioxus::behavior::splitter::{key_value, KeyContext};
let bar = KeyContext { inline: true, rtl: false, growth: 1.0, current: 35.0, min: 15.0, max: 70.0, step: 5.0, restore: None };
assert_eq!(key_value(&Key::ArrowRight, false, bar), Some((40.0, None)));
assert_eq!(key_value(&Key::ArrowRight, true, bar), Some((85.0, None)));
assert_eq!(key_value(&Key::ArrowRight, false, KeyContext { rtl: true, ..bar }), Some((30.0, None)));
assert_eq!(key_value(&Key::Enter, false, bar), Some((15.0, Some(35.0))));
assert_eq!(key_value(&Key::Enter, false, KeyContext { current: 15.0, restore: Some(35.0), ..bar }), Some((35.0, None)));
assert_eq!(key_value(&Key::ArrowDown, false, bar), None);