gpui_component/event.rs
1use gpui::{App, ClickEvent, InteractiveElement, Stateful, Window};
2
3pub trait InteractiveElementExt: InteractiveElement {
4 /// Set the listener for a double click event.
5 fn on_double_click(
6 mut self,
7 listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
8 ) -> Self
9 where
10 Self: Sized,
11 {
12 self.interactivity().on_click(move |event, window, cx| {
13 if event.click_count() == 2 {
14 listener(event, window, cx);
15 }
16 });
17 self
18 }
19}
20
21impl<E: InteractiveElement> InteractiveElementExt for Stateful<E> {}