Open attran1 opened 1 day ago
I have followed the Json Editor example and added ui.small_button("✅").clicked(). It works fine but I prefer to have the checkbox show at the beginning of the string.
Hi, the ordering of the button/checkbox comes down to the order in which you render elements within the on_render
render hook. The default layout within the hook is horizontal, left to right. See below for a minimal example:
JsonTree::new("id", &value)
.on_render(|ui, ctx| {
if let RenderContext::BaseValue(_) = ctx {
// Render a button before rendering a base value (string, bool, number, null).
ui.small_button("✅");
ui.add_space(5.0);
}
// Render the JSON as normal.
ctx.render_default(ui);
})
.show(ui);
The RenderBaseValueContext
struct that is matched in this example contains information about the base value being rendered. So you could conditionally render a UI element for strings only, if you so wished. See here for more info on the RenderContext
handles.
Hope this helps!
Hello,
I am new to Rust and I have interest using your egui_json_tree. I have one request but I could not find a discussion forum. So I have to file as an issue to be able to reach to some developers.
Do you have an example code where I can have checkbox for each tree to allow my users to select items from the tree?
Thank you, Anthony