2

I'm working on a GTK4 application in Rust but having difficulty understanding EntryBuffers. I cant seem to find a function that returns the contained text of an EntryBuffer. I've tried to_string(), but I always get a string containing "EntryBuffer" instead of the actual text inputted.

let input = Entry::new();
println!("input: {}", input.buffer().to_string()); // returns "EntryBuffer"
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366

1 Answers1

1

If you include the gtk4 prelude (use gtk4::prelude::*) then you will have EntryBufferExtManual in scope, which is implemented by EntryBuffer. This has a text() method that returns the contents of the buffer as a String.

println!("input: {}", input.buffer().text());
cdhowie
  • 158,093
  • 24
  • 286
  • 300