Reputation: 4450
I would like to set the placeholder in the textbox input field, but I am not succeeding.
Can you help me?
use druid::widget::{TextBox, Flex};
use druid::{AppLauncher, Data, Lens, Widget, WidgetExt};
#[derive(Clone, Data, Lens)]
struct AppState {
text: String,
}
fn main() {
let main_window = druid::WindowDesc::new(build_ui())
.title("Window with input field")
.window_size((400.0, 200.0));
let initial_state = AppState {
text: String::new(),
};
AppLauncher::with_window(main_window)
.log_to_console()
.launch(initial_state)
.expect("Error launching the app");
}
fn build_ui() -> impl Widget<AppState> {
let textbox = TextBox::new()
.lens(AppState::text);
Flex::column()
.with_child(textbox)
.center()
}
Upvotes: 0
Views: 35