'How do I get the string value contained in an EntryBuffer?
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"
Solution 1:[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());
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cdhowie |
