Skip to content

Commit e950fd5

Browse files
committed
update search example to use auto_reset_expanded setting
1 parent 10d98d2 commit e950fd5

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

examples/demo/src/apps/search.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,18 @@ impl Show for SearchExample {
2929
ui.add_space(10.0);
3030

3131
ui.label("Search:");
32-
let (text_edit_response, clear_button_response) = ui
33-
.horizontal(|ui| {
34-
let text_edit_response = ui.text_edit_singleline(&mut self.search_input);
35-
let clear_button_response = ui.button("Clear");
36-
(text_edit_response, clear_button_response)
37-
})
38-
.inner;
32+
ui.horizontal(|ui| {
33+
ui.text_edit_singleline(&mut self.search_input);
34+
if ui.button("Clear").clicked() {
35+
self.search_input.clear();
36+
}
37+
});
3938

4039
let response = JsonTree::new(self.title(), &self.value)
4140
.default_expand(DefaultExpand::SearchResults(&self.search_input))
41+
.auto_reset_expanded(true)
4242
.show(ui);
4343

44-
if text_edit_response.changed() {
45-
response.reset_expanded(ui);
46-
}
47-
48-
if clear_button_response.clicked() {
49-
self.search_input.clear();
50-
response.reset_expanded(ui);
51-
}
52-
5344
if ui.button("Reset expanded").clicked() {
5445
response.reset_expanded(ui);
5546
}

examples/demo/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct DemoApp {
1515

1616
impl Default for DemoApp {
1717
fn default() -> Self {
18-
let complex_object = json!({"foo": [1, 2, [3]], "bar": { "qux" : false, "thud": { "a/b": [4, 5, { "m~n": "Greetings!" }]}, "grep": 21}, "baz": null});
18+
let complex_object = json!({"foo": [1, 2, ["grep"]], "bar": { "qux" : false, "thud": { "a/b": [4, 5, { "m~n": "Greetings!" }]}, "grep": 21}, "baz": null});
1919
let long_strings_object = json!({
2020
"baz": "Ullamco ipsum proident occaecat eiusmod ea aute ex non cupidatat laboris duis amet cupidatat. Ullamco sint do enim consectetur Lorem occaecat mollit. Aliquip voluptate ullamco consectetur adipisicing elit fugiat labore laboris. Occaecat non incididunt duis consectetur aliquip dolore cillum eiusmod. Qui sunt est excepteur laborum.",
2121
"bar": [

0 commit comments

Comments
 (0)