Skip to content

Commit 14c638c

Browse files
committed
fix
1 parent a9af277 commit 14c638c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/inspector.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,6 +4472,7 @@ where
44724472
.apply(border_width_style(BoxEdge::ALL, border_width.signal()));
44734473
wrapper.el = wrapper.el.on_click_outside_with_system(
44744474
|In((entity, _)), mut focused_option: ResMut<InputFocus>, childrens: Query<&Children>| {
4475+
// TODO: use a relationship for this
44754476
if let Some(&text_input) = i_born(entity, &childrens, 0)
44764477
&& focused_option.0 == Some(text_input)
44774478
{
@@ -4828,6 +4829,7 @@ where
48284829
}))
48294830
.on_change_with_system(clone!((parse_failed, value, focused) move |
48304831
In((ui_entity, text)): In<(Entity, String)>,
4832+
child_ofs: Query<&ChildOf>,
48314833
mut field: TargetField
48324834
| {
48334835
if !focused.get() {
@@ -4838,7 +4840,9 @@ where
48384840
Ok(new) => {
48394841
if new != value.get() {
48404842
parse_failed.set(None);
4841-
field.update(ui_entity, new.to_dynamic());
4843+
if let Ok(&ChildOf(parent)) = child_ofs.get(ui_entity) {
4844+
field.update(parent, new.to_dynamic());
4845+
}
48424846
}
48434847
}
48444848
Err(e) => {
@@ -4857,7 +4861,9 @@ pub fn string_field<T: PartialReflect + From<String> + Into<String> + Default +
48574861
-> impl Element {
48584862
let padding = GLOBAL_PADDING.clone();
48594863
let focused = Mutable::new(false);
4864+
let value: Mutable<T> = Mutable::new(T::default());
48604865
TextInputField::new(T::default(), Into::into)
4866+
.with_value(value.clone())
48614867
.with_focused(focused.clone())
48624868
.cursor(CursorIcon::System(SystemCursorIcon::Text))
48634869
// TODO: without this initial static value, width snaps from 100% due to signal runtime lag
@@ -4883,9 +4889,19 @@ pub fn string_field<T: PartialReflect + From<String> + Into<String> + Default +
48834889
// TODO: remove for multiline
48844890
.with_text_input_node(|mut node| node.mode = TextInputMode::SingleLine)
48854891
.on_change_with_system(
4886-
move |In((ui_entity, text)): In<(Entity, String)>, mut field: TargetField| {
4887-
field.update(ui_entity, T::from(text).to_dynamic());
4888-
},
4892+
clone!((value, focused) move |In((ui_entity, text)): In<(Entity, String)>,
4893+
child_ofs: Query<&ChildOf>,
4894+
mut field: TargetField| {
4895+
if !focused.get() {
4896+
return;
4897+
}
4898+
let new = T::from(text);
4899+
if new != *value.lock_ref() {
4900+
if let Ok(&ChildOf(parent)) = child_ofs.get(ui_entity) {
4901+
field.update(parent, new.to_dynamic());
4902+
}
4903+
}
4904+
}),
48894905
)
48904906
})
48914907
.on_click(move || focused.set_neq(true))

0 commit comments

Comments
 (0)