2023-03-24 16:32:42 +00:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-01-16 17:45:02 +00:00
|
|
|
launch_desktop(app);
|
2023-03-24 16:32:42 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn app() -> Element {
|
2024-01-16 07:24:59 +00:00
|
|
|
let mut elements = use_signal(Vec::<Rc<MountedData>>::new);
|
|
|
|
let mut running = use_signal(|| true);
|
2023-03-24 16:32:42 +00:00
|
|
|
|
2024-01-15 21:06:05 +00:00
|
|
|
use_future(move || async move {
|
2023-03-24 16:32:42 +00:00
|
|
|
let mut focused = 0;
|
2024-01-16 05:12:44 +00:00
|
|
|
if running() {
|
2023-03-24 16:32:42 +00:00
|
|
|
loop {
|
|
|
|
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
2024-01-11 07:26:26 +00:00
|
|
|
if let Some(element) = elements.with(|f| f.get(focused).cloned()) {
|
2024-01-11 03:33:34 +00:00
|
|
|
_ = element.set_focus(true).await;
|
2023-03-24 16:32:42 +00:00
|
|
|
} else {
|
|
|
|
focused = 0;
|
|
|
|
}
|
|
|
|
focused += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-01-16 19:18:46 +00:00
|
|
|
rsx! {
|
2023-03-24 16:32:42 +00:00
|
|
|
div {
|
|
|
|
h1 { "Input Roulette" }
|
|
|
|
for i in 0..100 {
|
|
|
|
input {
|
|
|
|
value: "{i}",
|
|
|
|
onmounted: move |cx| {
|
|
|
|
elements.write().push(cx.inner().clone());
|
|
|
|
},
|
|
|
|
oninput: move |_| {
|
|
|
|
running.set(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-14 05:12:21 +00:00
|
|
|
}
|
2023-03-24 16:32:42 +00:00
|
|
|
}
|