mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
fix tui example links (#607)
This commit is contained in:
parent
7e3a6fb4a4
commit
f89cd20455
3 changed files with 15 additions and 79 deletions
|
@ -134,31 +134,33 @@ cargo run --example hello_world
|
||||||
|
|
||||||
## Terminal UI
|
## Terminal UI
|
||||||
|
|
||||||
[tui_border](./tui_border.rs)
|
[tui_all_events](../packages/tui/examples/tui_all_events.rs) - All of the terminal events
|
||||||
|
|
||||||
[tui_buttons](./tui_buttons.rs)
|
[tui_border](../packages/tui/examples/tui_border.rs) - Different styles of borders and corners
|
||||||
|
|
||||||
[tui_color_test](./tui_color_test.rs)
|
[tui_buttons](../packages/tui/examples/tui_buttons.rs) - A grid of buttons that work demonstrate the focus system
|
||||||
|
|
||||||
[tui_components](./tui_components.rs)
|
[tui_color_test](../packages/tui/examples/tui_color_test.rs) - Grid of colors to demonstrate compatablility with different terminal color rendering modes
|
||||||
|
|
||||||
[tui_frame](./tui_frame.rs)
|
[tui_colorpicker](../packages/tui/examples/tui_colorpicker.rs) - A colorpicker
|
||||||
|
|
||||||
[tui_hover](./tui_hover.rs)
|
[tui_components](../packages/tui/examples/tui_components.rs) - Simple component example
|
||||||
|
|
||||||
[tui_keys](./tui_keys.rs)
|
[tui_flex](../packages/tui/examples/tui_flex.rs) - Flexbox support
|
||||||
|
|
||||||
[tui_list](./tui_list.rs)
|
[tui_hover](../packages/tui/examples/tui_hover.rs) - Detect hover and mouse events
|
||||||
|
|
||||||
[tui_margin](./tui_margin.rs)
|
[tui_list](../packages/tui/examples/tui_list.rs) - Renders a list of items
|
||||||
|
|
||||||
[tui_quadrants](./tui_quadrants.rs)
|
[tui_margin](../packages/tui/examples/tui_margin.rs) - Margins around flexboxes
|
||||||
|
|
||||||
[tui_readme](./tui_readme.rs)
|
[tui_quadrants](../packages/tui/examples/tui_quadrants.rs) - Four quadrants
|
||||||
|
|
||||||
[tui_task](./tui_task.rs)
|
[tui_readme](../packages/tui/examples/tui_readme.rs) - The readme example
|
||||||
|
|
||||||
[tui_text](./tui_text.rs)
|
[tui_task](../packages/tui/examples/tui_task.rs) - Background tasks
|
||||||
|
|
||||||
|
[tui_text](../packages/tui/examples/tui_text.rs) - Simple text example
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
Missing Features
|
Missing Features
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
use dioxus::events::WheelEvent;
|
|
||||||
use dioxus::prelude::*;
|
|
||||||
use dioxus_html::geometry::ScreenPoint;
|
|
||||||
use dioxus_html::input_data::keyboard_types::Code;
|
|
||||||
use dioxus_html::input_data::MouseButtonSet;
|
|
||||||
use dioxus_html::on::{KeyboardEvent, MouseEvent};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
dioxus_tui::launch(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
|
||||||
let key = use_state(&cx, || "".to_string());
|
|
||||||
let mouse = use_state(&cx, ScreenPoint::zero);
|
|
||||||
let count = use_state(&cx, || 0);
|
|
||||||
let buttons = use_state(&cx, MouseButtonSet::empty);
|
|
||||||
let mouse_clicked = use_state(&cx, || false);
|
|
||||||
|
|
||||||
let key_down_handler = move |evt: KeyboardEvent| {
|
|
||||||
match evt.data.code() {
|
|
||||||
Code::ArrowLeft => count.set(count + 1),
|
|
||||||
Code::ArrowRight => count.set(count - 1),
|
|
||||||
Code::ArrowUp => count.set(count + 10),
|
|
||||||
Code::ArrowDown => count.set(count - 10),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
key.set(format!(
|
|
||||||
"{:?} repeating: {:?}",
|
|
||||||
evt.key(),
|
|
||||||
evt.is_auto_repeating()
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
cx.render(rsx! {
|
|
||||||
div {
|
|
||||||
width: "100%",
|
|
||||||
height: "10px",
|
|
||||||
background_color: "red",
|
|
||||||
justify_content: "center",
|
|
||||||
align_items: "center",
|
|
||||||
flex_direction: "column",
|
|
||||||
onkeydown: key_down_handler,
|
|
||||||
onwheel: move |evt: WheelEvent| {
|
|
||||||
count.set(count + evt.data.delta().strip_units().y as i64);
|
|
||||||
},
|
|
||||||
ondrag: move |evt: MouseEvent| {
|
|
||||||
mouse.set(evt.data.screen_coordinates());
|
|
||||||
},
|
|
||||||
onmousedown: move |evt: MouseEvent| {
|
|
||||||
mouse.set(evt.data.screen_coordinates());
|
|
||||||
buttons.set(evt.data.held_buttons());
|
|
||||||
mouse_clicked.set(true);
|
|
||||||
},
|
|
||||||
onmouseup: move |evt: MouseEvent| {
|
|
||||||
buttons.set(evt.data.held_buttons());
|
|
||||||
mouse_clicked.set(false);
|
|
||||||
},
|
|
||||||
|
|
||||||
"count: {count:?}",
|
|
||||||
"key: {key}",
|
|
||||||
"mouse buttons: {buttons:?}",
|
|
||||||
"mouse pos: {mouse:?}",
|
|
||||||
"mouse button pressed: {mouse_clicked}"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
Loading…
Reference in a new issue