some issue

This commit is contained in:
2024-10-31 19:00:39 +01:00
parent 92ab35c4ef
commit 55f52f786f
4 changed files with 83 additions and 35 deletions
+48 -18
View File
@@ -1,23 +1,53 @@
use osui::{oml, ui::*, App};
use osui::{key::KeyKind, oml, ui::*, App};
fn main() {
let mut app_screen = App::new();
app_screen.set_component(app());
app_screen.set_component(oml!(
tab {
div {
// Some welcome text
text("Welcome! This is the OSUI Tutorial! Press tab to go to the next Page or press Shift+Tab to go to a previous page";)
}
// A button example With a div
div {
text("On the bottom there is a button. To hover it click the down key, Then press enter to select it";)
// Button
button("Click me!"; y = 3, style = Style {
hover_fg: Color::Magenta,
..Default::default()
}, on_click = |btn| {
btn.text = "Press tab to go to the next page".to_string();
})
}
div {
text("This is a menu, ";)
// Button
menu(y = 2, items = vec![
String::from("Item 1"),
String::from("Item 2"),
String::from("Item 3"),
String::from("Item 4"),
String::from("Item 5"),
String::from("Item 6"),
], on_click = |m, k| {
if k.kind == KeyKind::Escape {
return ClickResponse::Exit;
} else if k.kind == KeyKind::Enter {
m.items[m.selected] = "Press Tab to go to the next page".to_string();
}
ClickResponse::None
})
}
}
));
app_screen.run();
}
fn app() -> Box<Tab> {
oml!(
tab {
text("Hello!"; style = Style {
hover_fg: Color::Red,
..Default::default()
})
button("Hello 2!"; y = 1, style = Style {
hover_fg: Color::Green,
..Default::default()
})
menu(items = vec![String::from("Hello, World!"), String::from("Item 2!")])
}
)
}