Skip to content

Commit b5783d1

Browse files
authored
fix: select out of terminal (#31)
1 parent 778cc83 commit b5783d1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/egui-term/src/view.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ impl Widget for TerminalView<'_> {
6363
fn ui(mut self, ui: &mut egui::Ui) -> Response {
6464
let widget_id = self.widget_id;
6565
let mut state = TerminalViewState::load(ui.ctx(), widget_id);
66-
let mut layout_opt = None;
6766

68-
ui.horizontal(|ui| {
69-
let size_p = Vec2::new(self.size.x - InteractiveScrollbar::WIDTH, self.size.y);
70-
let (layout, painter) = ui.allocate_painter(size_p, egui::Sense::click());
67+
let size_p = Vec2::new(self.size.x - InteractiveScrollbar::WIDTH, self.size.y);
68+
let (layout, painter) = ui.allocate_painter(size_p, egui::Sense::click());
7169

70+
ui.horizontal(|ui| {
7271
if layout.contains_pointer() {
7372
*self.options.active_tab_id = Some(self.widget_id);
7473
layout.ctx.set_cursor_icon(CursorIcon::Text);
@@ -82,7 +81,9 @@ impl Widget for TerminalView<'_> {
8281

8382
// context menu
8483
if let Some(pos) = state.cursor_position {
85-
self.context_menu(pos, &layout, ui);
84+
if !out_of_terminal(pos, &layout) {
85+
self.context_menu(pos, &layout, ui);
86+
}
8687
}
8788
if ui.input(|input_state| input_state.pointer.primary_clicked()) {
8889
state.cursor_position = None;
@@ -118,9 +119,8 @@ impl Widget for TerminalView<'_> {
118119
term.show(&mut state, &layout, &painter);
119120

120121
state.store(ui.ctx(), widget_id);
121-
layout_opt = Some(layout);
122122
});
123-
layout_opt.unwrap()
123+
layout
124124
}
125125
}
126126

0 commit comments

Comments
 (0)