mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Introduce InteractiveElement::capture_any_mouse_{down,up}
This commit is contained in:
parent
5781cf6604
commit
8273865fa3
@ -62,6 +62,18 @@ impl Interactivity {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn capture_any_mouse_down(
|
||||
&mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
) {
|
||||
self.mouse_down_listeners
|
||||
.push(Box::new(move |event, bounds, phase, cx| {
|
||||
if phase == DispatchPhase::Capture && bounds.visibly_contains(&event.position, cx) {
|
||||
(listener)(event, cx)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn on_any_mouse_down(
|
||||
&mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
@ -90,6 +102,18 @@ impl Interactivity {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn capture_any_mouse_up(
|
||||
&mut self,
|
||||
listener: impl Fn(&MouseUpEvent, &mut WindowContext) + 'static,
|
||||
) {
|
||||
self.mouse_up_listeners
|
||||
.push(Box::new(move |event, bounds, phase, cx| {
|
||||
if phase == DispatchPhase::Capture && bounds.visibly_contains(&event.position, cx) {
|
||||
(listener)(event, cx)
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn on_any_mouse_up(
|
||||
&mut self,
|
||||
listener: impl Fn(&MouseUpEvent, &mut WindowContext) + 'static,
|
||||
@ -384,6 +408,14 @@ pub trait InteractiveElement: Sized {
|
||||
self
|
||||
}
|
||||
|
||||
fn capture_any_mouse_down(
|
||||
mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
) -> Self {
|
||||
self.interactivity().capture_any_mouse_down(listener);
|
||||
self
|
||||
}
|
||||
|
||||
fn on_any_mouse_down(
|
||||
mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
@ -401,6 +433,14 @@ pub trait InteractiveElement: Sized {
|
||||
self
|
||||
}
|
||||
|
||||
fn capture_any_mouse_up(
|
||||
mut self,
|
||||
listener: impl Fn(&MouseUpEvent, &mut WindowContext) + 'static,
|
||||
) -> Self {
|
||||
self.interactivity().capture_any_mouse_up(listener);
|
||||
self
|
||||
}
|
||||
|
||||
fn on_mouse_down_out(
|
||||
mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
|
Loading…
Reference in New Issue
Block a user