Skip to main content

Input

Struct Input 

Source
pub struct Input(/* private fields */);
Expand description

Builder for an Input component

Implementations§

Source§

impl Input

Source

pub fn new() -> Self

Create a new input

Examples found in repository?
examples/simple_plugin.rs (line 145)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}
Source

pub fn value(self, value: impl Into<String>) -> Self

Set the input value

Source

pub fn placeholder(self, placeholder: impl Into<String>) -> Self

Set the placeholder text

Examples found in repository?
examples/simple_plugin.rs (line 146)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}
Source

pub fn on_change(self, handler: impl Into<String>) -> Self

Set the on_change handler

Examples found in repository?
examples/simple_plugin.rs (line 147)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}
Source

pub fn on_submit(self, handler: impl Into<String>) -> Self

Set the on_submit handler

Source

pub fn bind_value(self, path: impl Into<String>) -> Self

Bind the value to a data path

Examples found in repository?
examples/simple_plugin.rs (line 159)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}
Source

pub fn width(self, width: i64) -> Self

Set width

Source

pub fn disabled(self, disabled: bool) -> Self

Set whether the input is disabled

Examples found in repository?
examples/simple_plugin.rs (line 158)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}

Trait Implementations§

Source§

impl Builder for Input

Source§

fn build(self) -> PluginValue

Convert this builder to a PluginValue
Source§

impl Default for Input

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnsafeUnpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.