mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Removed EventHandler from workspace in favor of mouse event handler
This commit is contained in:
parent
0f43ef9331
commit
e44536344a
4 changed files with 13 additions and 10 deletions
|
@ -44,6 +44,11 @@ impl MouseEventHandler {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn capture_all(mut self) -> Self {
|
||||
self.handlers = HandlerSet::capture_all();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn on_move(
|
||||
mut self,
|
||||
handler: impl Fn(MoveRegionEvent, &mut EventContext) + 'static,
|
||||
|
|
|
@ -79,7 +79,6 @@ impl Presenter {
|
|||
self.rendered_views.remove(view_id);
|
||||
}
|
||||
for view_id in &invalidation.updated {
|
||||
dbg!(view_id);
|
||||
self.rendered_views.insert(
|
||||
*view_id,
|
||||
cx.render_view(RenderParams {
|
||||
|
@ -152,7 +151,6 @@ impl Presenter {
|
|||
|
||||
if cx.window_is_active(self.window_id) {
|
||||
if let Some(event) = self.last_mouse_moved_event.clone() {
|
||||
println!("Redispatching mouse moved");
|
||||
self.dispatch_event(event, true, cx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ impl MouseRegion {
|
|||
view_id,
|
||||
discriminant,
|
||||
bounds,
|
||||
handlers: HandlerSet::handle_all(),
|
||||
handlers: HandlerSet::capture_all(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ pub struct HandlerSet {
|
|||
}
|
||||
|
||||
impl HandlerSet {
|
||||
pub fn handle_all() -> Self {
|
||||
pub fn capture_all() -> Self {
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut set: HashMap<
|
||||
(Discriminant<MouseRegionEvent>, Option<MouseButton>),
|
||||
|
|
|
@ -2071,11 +2071,11 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> {
|
||||
fn render_disconnected_overlay(&self, cx: &mut RenderContext<Workspace>) -> Option<ElementBox> {
|
||||
if self.project.read(cx).is_read_only() {
|
||||
let theme = &cx.global::<Settings>().theme;
|
||||
Some(
|
||||
EventHandler::new(
|
||||
MouseEventHandler::new::<Workspace, _, _>(0, cx, |_, cx| {
|
||||
let theme = &cx.global::<Settings>().theme;
|
||||
Label::new(
|
||||
"Your connection to the remote project has been lost.".to_string(),
|
||||
theme.workspace.disconnected_overlay.text.clone(),
|
||||
|
@ -2083,9 +2083,9 @@ impl Workspace {
|
|||
.aligned()
|
||||
.contained()
|
||||
.with_style(theme.workspace.disconnected_overlay.container)
|
||||
.boxed(),
|
||||
)
|
||||
.capture_all::<Self>(0)
|
||||
.boxed()
|
||||
})
|
||||
.capture_all()
|
||||
.boxed(),
|
||||
)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue