This commit is contained in:
2024-10-21 11:03:38 +08:00
parent 80566a4cc5
commit 579ffead41
2 changed files with 10 additions and 3 deletions

View File

@@ -8,6 +8,11 @@ use ratatui::{
Frame,
};
pub enum InputEvent {
Compelete,
None,
}
#[derive(Default)]
pub struct InputComponent {
name: String,
@@ -33,7 +38,7 @@ impl Component for InputComponent {
input
}
fn event_handler(&mut self, event: &Event) -> io::Result<()> {
fn event_handler(&mut self, event: &Event) -> io::Result<InputEvent> {
match event {
Event::Key(KeyEvent {
kind: KeyEventKind::Press,

View File

@@ -25,6 +25,7 @@ pub struct Home {
table: ListComponent,
help: HelpComponent,
setting: SettingView,
event_recive: [bool;4],
}
impl Default for Home {
@@ -36,6 +37,7 @@ impl Default for Home {
.name("Connections".to_string()),
help: HelpComponent::default(),
setting: SettingView::default(),
event_recive: [true, false, false, false]
}
}
}
@@ -58,8 +60,8 @@ impl View for Home {
}
fn handle_event(&mut self, event: &Event) -> io::Result<()> {
self.input.event_handler(event)?;
self.table.event_handler(event)?;
if self.event_recive[0] {self.input.event_handler(event)?};
if self.event_recive[1] {self.table.event_handler(event)?};
Ok(())
}
}