From 35c679c86909d50e633431c141b11252e38ce858 Mon Sep 17 00:00:00 2001 From: sam edelsten <samedelsten1@gmail.com> Date: Mon, 11 Sep 2023 18:39:13 +0100 Subject: [PATCH] clear inactive editor selection --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3a04520..b8bc4db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -391,6 +391,7 @@ impl Plugin for CosmicEditPlugin { cosmic_edit_redraw_buffer.before(on_scale_factor_change), blink_cursor, hide_inactive_cursor, + clear_inactive_selection, ), ) .init_resource::<ActiveEditor>() @@ -1234,6 +1235,21 @@ fn hide_inactive_cursor( } } +fn clear_inactive_selection( + mut cosmic_editor_q: Query<(Entity, &mut CosmicEditor)>, + active_editor: Res<ActiveEditor>, +) { + if !active_editor.is_changed() || active_editor.entity.is_none() { + return; + } + + for (e, mut editor) in &mut cosmic_editor_q.iter_mut() { + if e != active_editor.entity.unwrap() { + editor.0.set_select_opt(None); + } + } +} + fn cosmic_edit_redraw_buffer( windows: Query<&Window, With<PrimaryWindow>>, mut images: ResMut<Assets<Image>>, -- GitLab