Fix bug
This commit is contained in:
parent
35e9b0f827
commit
cfc92ecb55
|
@ -1,4 +1,4 @@
|
|||
use crate::events::is_supported_event;
|
||||
use crate::{events::is_supported_event, tick::IntrinsicTextNode};
|
||||
use bevy::{
|
||||
ecs::{entity::Entity, system::Command, world::World},
|
||||
hierarchy::{BuildWorldChildren, Children, DespawnRecursive, Parent},
|
||||
|
@ -323,10 +323,13 @@ impl BevyTemplateNode {
|
|||
.id()
|
||||
}
|
||||
Self::IntrinsicTextNode(text) => world
|
||||
.spawn(TextBundle {
|
||||
text: text.clone(),
|
||||
..default()
|
||||
})
|
||||
.spawn((
|
||||
TextBundle {
|
||||
text: text.clone(),
|
||||
..default()
|
||||
},
|
||||
IntrinsicTextNode,
|
||||
))
|
||||
.id(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ use crate::{
|
|||
};
|
||||
use bevy::{
|
||||
ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
world::{Mut, World},
|
||||
},
|
||||
hierarchy::Parent,
|
||||
text::Text,
|
||||
utils::HashMap,
|
||||
};
|
||||
use std::{any::Any, mem, rc::Rc, sync::Arc};
|
||||
|
@ -68,7 +68,7 @@ fn dispatch_ui_events(
|
|||
) {
|
||||
for (mut target, name, data) in events {
|
||||
let mut target_element_id = ui_root.bevy_ui_entity_to_element_id.get(&target).copied();
|
||||
while target_element_id.is_none() || world.entity(target).contains::<Text>() {
|
||||
while target_element_id.is_none() || world.entity(target).contains::<IntrinsicTextNode>() {
|
||||
target = world.entity(target).get::<Parent>().unwrap().get();
|
||||
target_element_id = ui_root.bevy_ui_entity_to_element_id.get(&target).copied();
|
||||
}
|
||||
|
@ -122,3 +122,6 @@ fn render_ui(root_entity: Entity, ui_root: &mut UiRoot, world: &mut World) {
|
|||
world,
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct IntrinsicTextNode;
|
||||
|
|
Loading…
Reference in a new issue