fixed selection when removing a state or a transition
@@ -156,9 +156,8 @@ impl NodeContextMenu {
},
))
} else if message.destination == self.remove {
- let states_to_remove =
if let Selection::Absm(ref selection) = editor_scene.selection {
- selection
+ let states_to_remove = selection
.entities
.iter()
.cloned()
@@ -169,10 +168,7 @@ impl NodeContextMenu {
None
}
})
- .collect::<Vec<_>>()
- } else {
- Default::default()
- };
+ .collect::<Vec<_>>();
// Gather every transition that leads from/to any of states to remove.
let transitions_to_remove = machine.layers()[layer_index]
@@ -189,8 +185,11 @@ impl NodeContextMenu {
}
});
+ let mut new_selection = selection.clone();
+ new_selection.entities.clear();
+
let mut group = vec![SceneCommand::new(ChangeSelectionCommand::new(
- Default::default(),
+ Selection::Absm(new_selection),
editor_scene.selection.clone(),
))];
@@ -213,6 +212,7 @@ impl NodeContextMenu {
sender
.send(Message::do_scene_command(CommandGroup::from(group)))
.unwrap();
+ }
} else if message.destination() == self.set_as_entry_state {
sender
.send(Message::do_scene_command(SetMachineEntryStateCommand {
@@ -271,6 +271,10 @@ impl TransitionContextMenu {
) {
if let Some(MenuItemMessage::Click) = message.data() {
if message.destination == self.remove {
+ if let Selection::Absm(ref selection) = editor_scene.selection {
+ let mut new_selection = selection.clone();
+ new_selection.entities.clear();
+
let transition_ref = ui
.node(self.placement_target)
.query_component::<TransitionView>()
@@ -278,7 +282,7 @@ impl TransitionContextMenu {
let group = vec![
SceneCommand::new(ChangeSelectionCommand::new(
- Default::default(),
+ Selection::Absm(new_selection),
editor_scene.selection.clone(),
)),
SceneCommand::new(DeleteTransitionCommand::new(
@@ -292,6 +296,7 @@ impl TransitionContextMenu {
.send(Message::do_scene_command(CommandGroup::from(group)))
.unwrap();
}
+ }
} else if let Some(PopupMessage::Placement(Placement::Cursor(target))) = message.data() {
if message.destination() == self.menu {
self.placement_target = *target;
