use tree.item_pathname in tree example
@@ -6,7 +6,7 @@ use fltk::{
enums::Event,
frame::Frame,
prelude::*,
- tree::{Tree, TreeItem, TreeSelect},
+ tree::{Tree, TreeItem, TreeReason, TreeSelect},
window::Window,
};
use std::cell::RefCell;
@@ -172,18 +172,23 @@ fn main() {
tree2.add("Second");
tree2.add("Third");
+ tree2.set_trigger(fltk::enums::CallbackTrigger::ReleaseAlways);
+
wind.make_resizable(true);
wind.show();
- but.set_callback(move |_| match tree2.get_selected_items() {
+ but.set_callback({
+ let tree2 = tree2.clone();
+ move |_| match tree2.get_selected_items() {
None => println!("No items selected"),
Some(vals) => print!(
"In total {} items selected:\n{}",
vals.len(),
vals.iter()
- .map(|i| i.label().unwrap() + "\n")
+ .map(|i| tree2.item_pathname(&i).unwrap() + "\n")
.collect::<String>()
),
+ }
});
app.run().unwrap();
