Enable mouse scrolling in TabViews (#363)
* Forward events from a TabView to the selected Tab * Forward mouse events to the front screen instead of the focused screen
This commit is contained in:
@@ -247,8 +247,7 @@ impl View for Layout {
|
||||
}
|
||||
|
||||
if position.y < self.last_size.y.saturating_sub(2 + cmdline_height) {
|
||||
if let Some(ref id) = self.focus {
|
||||
let screen = self.views.get_mut(id).unwrap();
|
||||
if let Some(screen) = self.get_current_screen_mut() {
|
||||
screen.view.on_event(event);
|
||||
}
|
||||
} else if position.y < self.last_size.y - cmdline_height {
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::cmp::{max, min};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use cursive::align::HAlign;
|
||||
use cursive::event::{Event, EventResult};
|
||||
use cursive::theme::{ColorStyle, ColorType, PaletteColor};
|
||||
use cursive::traits::View;
|
||||
use cursive::{Cursive, Printer, Vec2};
|
||||
@@ -100,6 +101,14 @@ impl View for TabView {
|
||||
tab.view.layout(Vec2::new(size.x, size.y - 1));
|
||||
}
|
||||
}
|
||||
|
||||
fn on_event(&mut self, event: Event) -> EventResult {
|
||||
if let Some(tab) = self.tabs.get_mut(self.selected) {
|
||||
tab.view.on_event(event)
|
||||
} else {
|
||||
EventResult::Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ViewExt for TabView {
|
||||
|
||||
Reference in New Issue
Block a user