@@ -439,9 +439,9 @@ impl TerminalEl {
|
|||||||
|
|
||||||
let mut region = MouseRegion::new(view_id, None, visible_bounds);
|
let mut region = MouseRegion::new(view_id, None, visible_bounds);
|
||||||
|
|
||||||
//Terminal Emulator controlled behavior:
|
// Terminal Emulator controlled behavior:
|
||||||
region = region
|
region = region
|
||||||
//Start selections
|
// Start selections
|
||||||
.on_down(
|
.on_down(
|
||||||
MouseButton::Left,
|
MouseButton::Left,
|
||||||
TerminalEl::generic_button_handler(
|
TerminalEl::generic_button_handler(
|
||||||
@@ -452,7 +452,7 @@ impl TerminalEl {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
//Update drag selections
|
// Update drag selections
|
||||||
.on_drag(MouseButton::Left, move |_prev, event, cx| {
|
.on_drag(MouseButton::Left, move |_prev, event, cx| {
|
||||||
if cx.is_parent_view_focused() {
|
if cx.is_parent_view_focused() {
|
||||||
if let Some(conn_handle) = connection.upgrade(cx.app) {
|
if let Some(conn_handle) = connection.upgrade(cx.app) {
|
||||||
@@ -463,7 +463,7 @@ impl TerminalEl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//Copy on up behavior
|
// Copy on up behavior
|
||||||
.on_up(
|
.on_up(
|
||||||
MouseButton::Left,
|
MouseButton::Left,
|
||||||
TerminalEl::generic_button_handler(
|
TerminalEl::generic_button_handler(
|
||||||
@@ -474,7 +474,7 @@ impl TerminalEl {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
//Handle click based selections
|
// Handle click based selections
|
||||||
.on_click(
|
.on_click(
|
||||||
MouseButton::Left,
|
MouseButton::Left,
|
||||||
TerminalEl::generic_button_handler(
|
TerminalEl::generic_button_handler(
|
||||||
@@ -485,37 +485,25 @@ impl TerminalEl {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
//Context menu
|
// Context menu
|
||||||
.on_click(
|
.on_click(
|
||||||
MouseButton::Right,
|
MouseButton::Right,
|
||||||
move |e @ MouseButtonEvent { position, .. }, cx| {
|
move |e @ MouseButtonEvent { position, .. }, cx| {
|
||||||
let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx.app) {
|
let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx.app) {
|
||||||
conn_handle.update(cx.app, |terminal, _cx| terminal.mouse_mode(e.shift))
|
conn_handle.update(cx.app, |terminal, _cx| terminal.mouse_mode(e.shift))
|
||||||
} else {
|
} else {
|
||||||
//If we can't get the model handle, probably can't deploy the context menu
|
// If we can't get the model handle, probably can't deploy the context menu
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
if !mouse_mode {
|
if !mouse_mode {
|
||||||
cx.dispatch_action(DeployContextMenu { position });
|
cx.dispatch_action(DeployContextMenu { position });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
//This handles both drag mode and mouse motion mode
|
|
||||||
//Mouse Move TODO
|
|
||||||
//This cannot be done conditionally for unknown reasons. Pending drag and drop rework.
|
|
||||||
//This also does not fire on right-mouse-down-move events wild.
|
|
||||||
.on_move(move |event, cx| {
|
|
||||||
if cx.is_parent_view_focused() {
|
|
||||||
if let Some(conn_handle) = connection.upgrade(cx.app) {
|
|
||||||
conn_handle.update(cx.app, |terminal, cx| {
|
|
||||||
terminal.mouse_move(&event, origin);
|
|
||||||
cx.notify();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if mode.contains(TermMode::MOUSE_MODE) {
|
// Mouse mode handlers:
|
||||||
|
// All mouse modes need the extra click handlers
|
||||||
|
if mode.intersects(TermMode::MOUSE_MODE) {
|
||||||
region = region
|
region = region
|
||||||
.on_down(
|
.on_down(
|
||||||
MouseButton::Right,
|
MouseButton::Right,
|
||||||
@@ -558,9 +546,22 @@ impl TerminalEl {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
//Mouse move manages both dragging and motion events
|
||||||
|
if mode.intersects(TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION) {
|
||||||
|
region = region
|
||||||
|
//TODO: This does not fire on right-mouse-down-move events.
|
||||||
|
.on_move(move |event, cx| {
|
||||||
|
if cx.is_parent_view_focused() {
|
||||||
|
if let Some(conn_handle) = connection.upgrade(cx.app) {
|
||||||
|
conn_handle.update(cx.app, |terminal, cx| {
|
||||||
|
terminal.mouse_move(&event, origin);
|
||||||
|
cx.notify();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Mouse drag isn't correct
|
|
||||||
//TODO: Nor is mouse motion. Move events aren't happening??
|
|
||||||
cx.scene.push_mouse_region(region);
|
cx.scene.push_mouse_region(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user