diff --git a/src/lib.rs b/src/lib.rs index 3a0452095c960793c03aaadc803a9bf8da0e2b71..222612d8b5edb486d691cb36b6018db9d518f0f5 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>() @@ -931,7 +932,11 @@ pub fn cosmic_edit_bevy_events( camera_transform, ) { let (x, y) = point(node_cursor_pos); - editor.action(&mut font_system.0, Action::Drag { x, y }); + if active_editor.is_changed() && !shift { + editor.action(&mut font_system.0, Action::Click { x, y }); + } else { + editor.action(&mut font_system.0, Action::Drag { x, y }); + } } return; } @@ -1234,6 +1239,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>>,