Fixed bug in mouse handler attaching

This commit is contained in:
Mikayla Maki 2022-08-19 17:19:35 -07:00
parent aed7c9bcfd
commit c42bf1c50b

View File

@ -499,23 +499,10 @@ impl TerminalEl {
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) {
//All mouse modes need the extra click handlers
if mode.intersects(TermMode::MOUSE_MODE) {
region = region
.on_down(
MouseButton::Right,
@ -558,6 +545,21 @@ impl TerminalEl {
),
)
}
//Mouse move manages both dragging and motion events
if mode.intersects(TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION) {
region = region
//This 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();
})
}
}
})
}
//TODO: Mouse drag isn't correct
//TODO: Nor is mouse motion. Move events aren't happening??