Skip to content

Commit

Permalink
Merge pull request #231 from irfanabliz/shortcuts-delete-nodes
Browse files Browse the repository at this point in the history
delete selected node
  • Loading branch information
Dimchikkk committed Oct 3, 2023
2 parents 107d2cf + acf1d1e commit c7e9fb8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ui_plugin/systems/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
AddRect, JsonNode, JsonNodeText, NodeType, UiState,
};

use super::ui_helpers::{Drawing, EditableText, InteractiveNode};
use super::ui_helpers::{Drawing, EditableText, InteractiveNode, VeloNode};
use crate::resources::{AppState, SaveDocRequest};

#[path = "../../macros.rs"]
Expand All @@ -50,6 +50,7 @@ pub fn keyboard_input_system(
(&Drawing<(String, Color)>, &GlobalTransform),
With<Drawing<(String, Color)>>,
>,
velo_node_query: Query<(Entity, &VeloNode)>,
) {
let camera_transform = camera_proj_query.single_mut();
let x = camera_transform.translation.x;
Expand Down Expand Up @@ -178,6 +179,14 @@ pub fn keyboard_input_system(
},
image: None,
});
} else if input.just_pressed(KeyCode::Delete) {
if let Some(id) = ui_state.entity_to_edit {
for (entity, node) in velo_node_query.iter() {
if node.id == id {
commands.entity(entity).despawn_recursive();
}
}
}
} else {
for (editable_text, mut cosmic_edit, mut cosmit_edit_history) in
&mut editable_text_query.iter_mut()
Expand Down

0 comments on commit c7e9fb8

Please sign in to comment.