gpui-component icon indicating copy to clipboard operation
gpui-component copied to clipboard

Buttons inside TitleBar still trigger window dragging (even when calling stop_propagation)

Open J2ane opened this issue 1 month ago • 2 comments

System information:

  • Kernel: kernel 6.16.8, x86_64
  • gpui version: "0.2.2"
  • gpui_component version: "0.4.0-preview0"
  • rust version: "rustc 1.91.0 (f8297e351 2025-10-28)"

Description: TitleBar supports dragging the window by default, which is expected. However, when placing buttons (Button) inside the TitleBar, clicking and dragging those buttons still triggers window dragging.

I tried calling: .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())

div()
    .flex()
    .items_center()
    .gap_2()
    .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
    .on_mouse_move(|_, _, cx| cx.stop_propagation())
    .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation())
    .child(
        Button::new("settings")
            .ghost()
            .icon(IconName::Settings)
            .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
            .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation())
    )
    .child(
        Button::new("user")
            .ghost()
            .icon(IconName::User)
            .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
            .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation())
    )

But the window dragging behavior still happens and is not prevented.

Expected behavior:

  • Clicking and dragging on buttons should not trigger window dragging.

Actual behavior:

  • Buttons are still treated as draggable regions, and stop_propagation() has no effect.

J2ane avatar Nov 06 '25 16:11 J2ane

I'm facing the same issue. I'm not sure if it's related to gpui_component, but in my case I'm using it on on_drag:

.on_drag(
  DragTab {
    index,
    tab_info: tab_info_drag.clone(),
  },
  |drag, _, window, cx| {
    cx.stop_propagation();
    cx.new(|_| drag.clone())
  },
)

1bye avatar Nov 06 '25 21:11 1bye

This is the known limitation.

We are also not have any draggable feature in TitleBar in our application.

huacnlee avatar Nov 07 '25 08:11 huacnlee