diff --git a/src/lib.rs b/src/lib.rs index 3a0452095c960793c03aaadc803a9bf8da0e2b71..b8bc4dbea982181e0de7bb6a3f2a71dfd690fc5c 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>>,