Skip to content

Commit 1f93a39

Browse files
committed
update readme/lib code example comments
1 parent da95ba9 commit 1f93a39

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let response = JsonTree::new("customised-tree", &value)
3737
..Default::default()
3838
}),
3939
)
40-
.default_expand(DefaultExpand::All)
40+
.default_expand(DefaultExpand::All) // Expand all arrays/object by default.
4141
.on_render(|ui, ctx| {
4242
// Customise rendering of the JsonTree, and/or handle interactions.
4343
match ctx {
@@ -62,8 +62,12 @@ let response = JsonTree::new("customised-tree", &value)
6262
})
6363
.show(ui);
6464

65-
// Reset the expanded state of all arrays/objects to respect the `default_expand` setting.
66-
response.reset_expanded(ui);
65+
// By default, the tree will expand/collapse all arrays/objects
66+
// to respect the `default_expand` setting when it changes.
67+
// If required, you can manually trigger this reset, e.g. after a button press:
68+
if ui.button("Reset").clicked() {
69+
response.reset_expanded(ui);
70+
}
6771
```
6872

6973
## Supported JSON Types

egui_json_tree/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//! ..Default::default()
3333
//! }),
3434
//! )
35-
//! .default_expand(DefaultExpand::All)
35+
//! .default_expand(DefaultExpand::All) // Expand all arrays/object by default.
3636
//! .on_render(|ui, ctx| {
3737
//! // Customise rendering of the JsonTree, and/or handle interactions.
3838
//! match ctx {
@@ -57,8 +57,12 @@
5757
//! })
5858
//! .show(ui);
5959
//!
60-
//! // Reset the expanded state of all arrays/objects to respect the `default_expand` setting.
61-
//! response.reset_expanded(ui);
60+
//! // By default, the tree will expand/collapse all arrays/objects
61+
//! // to respect the `default_expand` setting when it changes.
62+
//! // If required, you can manually trigger this reset, e.g. after a button press:
63+
//! if ui.button("Reset").clicked() {
64+
//! response.reset_expanded(ui);
65+
//! }
6266
//! # });
6367
//! ```
6468
//!

0 commit comments

Comments
 (0)