refactor: input_handler
use a mouse_point variable
This commit is contained in:
@@ -436,7 +436,7 @@ impl InputHandler {
|
|||||||
let is_c = || key_code == KeyCode::Char('c') || key_code == KeyCode::Char('C');
|
let is_c = || key_code == KeyCode::Char('c') || key_code == KeyCode::Char('C');
|
||||||
let is_q = || key_code == KeyCode::Char('q') || key_code == KeyCode::Char('Q');
|
let is_q = || key_code == KeyCode::Char('q') || key_code == KeyCode::Char('Q');
|
||||||
if key_modifier == KeyModifiers::CONTROL && is_c() || is_q() && !contains_filter {
|
if key_modifier == KeyModifiers::CONTROL && is_c() || is_q() && !contains_filter {
|
||||||
// Always just quit on Ctrl + c/C or q/Q, unless in FIlter status active
|
// Always just quit on Ctrl + c/C or q/Q, unless in Filter status active
|
||||||
self.quit();
|
self.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,22 +479,13 @@ impl InputHandler {
|
|||||||
MouseEventKind::ScrollUp => self.previous(),
|
MouseEventKind::ScrollUp => self.previous(),
|
||||||
MouseEventKind::ScrollDown => self.next(),
|
MouseEventKind::ScrollDown => self.next(),
|
||||||
MouseEventKind::Down(MouseButton::Left) => {
|
MouseEventKind::Down(MouseButton::Left) => {
|
||||||
let header = self.gui_state.lock().header_intersect(Rect::new(
|
let mouse_point = Rect::new(mouse_event.column, mouse_event.row, 1, 1);
|
||||||
mouse_event.column,
|
let header = self.gui_state.lock().header_intersect(mouse_point);
|
||||||
mouse_event.row,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
));
|
|
||||||
if let Some(header) = header {
|
if let Some(header) = header {
|
||||||
self.sort(header);
|
self.sort(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.gui_state.lock().panel_intersect(Rect::new(
|
self.gui_state.lock().panel_intersect(mouse_point);
|
||||||
mouse_event.column,
|
|
||||||
mouse_event.row,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user