Skip to content

Commit

Permalink
Modify textbox example to show programatically setting the textbox to…
Browse files Browse the repository at this point in the history
… edit mode
  • Loading branch information
geom3trik committed Jun 20, 2022
1 parent 9ac7631 commit b0c5079
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions examples/views/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,12 @@ fn main() {
Application::new(|cx| {
AppData { text: "This text is editable!".to_string() }.build(cx);

HStack::new(cx, |cx| {
VStack::new(cx, |cx| {
Textbox::new(cx, AppData::text)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0));
Textbox::new(cx, AppData::text)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0))
.class("align_right");
Textbox::new(cx, AppData::text)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0))
.class("align_center");
Textbox::new_multiline(cx, AppData::text, false)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0))
.height(Pixels(100.0));
Textbox::new_multiline(cx, AppData::text, true)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0))
.height(Pixels(100.0));
Textbox::new(cx, AppData::text)
.on_edit(|cx, text| cx.emit(AppEvent::SetText(text)))
.width(Pixels(200.0))
.on_build(|cx| {
cx.emit(TextEvent::StartEdit);
});

Label::new(cx, AppData::text).width(Pixels(200.0)).child_left(Pixels(5.0));
})
.space(Stretch(1.0))
.col_between(Pixels(10.0));
})
.title("Textbox")
.run();
Expand Down

0 comments on commit b0c5079

Please sign in to comment.