add multiline support to input

This commit is contained in:
2026-11-01 20:06:43 +07:00
parent 125fa3e62d
commit be05e12d16
4 changed files with 948 additions and 267 deletions
+9
View File
@@ -46,6 +46,7 @@ struct Gallery {
volume: f32,
input_state: Entity<InputState>,
password_state: Entity<InputState>,
notes_state: Entity<InputState>,
popover_open: bool,
menu_open: bool,
strategy: Option<Strategy>,
@@ -362,6 +363,11 @@ impl Render for Gallery {
Input::new("gallery-password", self.password_state.clone())
.placeholder("Password"),
)
.child(
Input::new("gallery-notes", self.notes_state.clone())
.placeholder("Notes — Enter breaks the line, cmd-Enter submits")
.rows(4),
)
.child(
div()
.text_xs()
@@ -1460,6 +1466,8 @@ fn main() {
let input_state = InputState::new(cx);
let password_state = InputState::new(cx);
password_state.update(cx, |state, cx| state.set_password(true, cx));
let notes_state = InputState::new(cx);
notes_state.update(cx, |state, cx| state.set_multiline(true, cx));
let bounds = Bounds::centered(None, size(px(720.0), px(560.0)), cx);
if let Err(err) = cx.open_window(
WindowOptions {
@@ -1497,6 +1505,7 @@ fn main() {
volume: 40.0,
input_state,
password_state,
notes_state,
popover_open: false,
menu_open: false,
strategy: Some(Strategy::Curated),