Events cannot start on text nodes

This commit is contained in:
JMS55 2023-12-16 17:43:55 -08:00
parent f6d0b3acd8
commit 91ac88def7

View file

@ -11,6 +11,7 @@ use bevy::{
world::{Mut, World},
},
hierarchy::Parent,
text::Text,
utils::HashMap,
};
use std::{any::Any, mem, rc::Rc, sync::Arc};
@ -69,7 +70,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() {
while target_element_id.is_none() || world.entity(target).contains::<Text>() {
target = world.entity(target).get::<Parent>().unwrap().get();
target_element_id = ui_root.bevy_ui_entity_to_element_id.get(&target).copied();
}