Remove `block_mouse_down` in favor of `stop_mouse_events_except_scroll` (#30401)
Michael Sloan
created 6 months ago
This method was added in #20649 to be an alternative of `occlude` which
allows scroll events. It seems a bit arbitrary to only stop left mouse
downs, so this seems like it's probably an improvement.
Release Notes:
- N/A
Change summary
crates/agent/src/inline_assistant.rs | 2 +-
crates/agent/src/inline_prompt_editor.rs | 2 +-
crates/editor/src/editor.rs | 2 +-
crates/extensions_ui/src/components/extension_card.rs | 2 +-
crates/gpui/src/elements/div.rs | 5 -----
crates/repl/src/session.rs | 2 +-
6 files changed, 5 insertions(+), 10 deletions(-)
Detailed changes
@@ -1445,7 +1445,7 @@ impl InlineAssistant {
style: BlockStyle::Flex,
render: Arc::new(move |cx| {
div()
- .block_mouse_down()
+ .block_mouse_except_scroll()
.bg(cx.theme().status().deleted_background)
.size_full()
.h(height as f32 * cx.window.line_height())
@@ -100,7 +100,7 @@ impl<T: 'static> Render for PromptEditor<T> {
v_flex()
.key_context("PromptEditor")
.bg(cx.theme().colors().editor_background)
- .block_mouse_down()
+ .block_mouse_except_scroll()
.gap_0p5()
.border_y_1()
.border_color(cx.theme().status().info_border)
@@ -15021,7 +15021,7 @@ impl Editor {
text_style = text_style.highlight(highlight_style);
}
div()
- .block_mouse_down()
+ .block_mouse_except_scroll()
.pl(cx.anchor_x)
.child(EditorElement::new(
&rename_editor,
@@ -48,7 +48,7 @@ impl RenderOnce for ExtensionCard {
.absolute()
.top_0()
.left_0()
- .block_mouse_down()
+ .block_mouse_except_scroll()
.cursor_default()
.size_full()
.items_center()
@@ -958,11 +958,6 @@ pub trait InteractiveElement: Sized {
self
}
- /// Stops propagation of left mouse down event.
- fn block_mouse_down(mut self) -> Self {
- self.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
- }
-
/// Block non-scroll mouse interactions with elements behind this element's hitbox. See
/// [`Hitbox::is_hovered`] for details.
///
@@ -162,7 +162,7 @@ impl EditorBlock {
div()
.id(cx.block_id)
- .block_mouse_down()
+ .block_mouse_except_scroll()
.flex()
.items_start()
.min_h(text_line_height)