mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix dialog layout and input
This commit is contained in:
parent
4fff7882aa
commit
25a298a2eb
@ -25,7 +25,6 @@ fn main() {
|
|||||||
.button("Quit", |s| s.quit()));
|
.button("Quit", |s| s.quit()));
|
||||||
// Show a popup on top of the view.
|
// Show a popup on top of the view.
|
||||||
siv.add_layer(Dialog::new(TextView::new("Try resizing the terminal!\n(Press 'q' to quit when you're done.)"))
|
siv.add_layer(Dialog::new(TextView::new("Try resizing the terminal!\n(Press 'q' to quit when you're done.)"))
|
||||||
.padding((0,0,0,0))
|
|
||||||
.dismiss_button("Ok"));
|
.dismiss_button("Ok"));
|
||||||
|
|
||||||
siv.run();
|
siv.run();
|
||||||
|
@ -151,9 +151,10 @@ impl View for Dialog {
|
|||||||
let content_size = self.content.get_min_size(content_req);
|
let content_size = self.content.get_min_size(content_req);
|
||||||
|
|
||||||
let mut buttons_size = Vec2::new(0,0);
|
let mut buttons_size = Vec2::new(0,0);
|
||||||
|
if !self.buttons.is_empty() { buttons_size.x += self.buttons.len() - 1; }
|
||||||
for button in self.buttons.iter() {
|
for button in self.buttons.iter() {
|
||||||
let s = button.view.get_min_size(req);
|
let s = button.view.get_min_size(req);
|
||||||
buttons_size.x += s.x + 1;
|
buttons_size.x += s.x;
|
||||||
buttons_size.y = max(buttons_size.y, s.y + 1);
|
buttons_size.y = max(buttons_size.y, s.y + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ impl View for Dialog {
|
|||||||
self.focus = Focus::Button(i+1);
|
self.focus = Focus::Button(i+1);
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
},
|
},
|
||||||
Event::KeyEvent(Key::Right) if i > 0 => {
|
Event::KeyEvent(Key::Left) if i > 0 => {
|
||||||
self.focus = Focus::Button(i-1);
|
self.focus = Focus::Button(i-1);
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user