pub struct Input(/* private fields */);Expand description
Builder for an Input component
Implementations§
Source§impl Input
impl Input
Sourcepub fn new() -> Self
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}Sourcepub fn placeholder(self, placeholder: impl Into<String>) -> Self
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}Sourcepub fn on_change(self, handler: impl Into<String>) -> Self
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}Sourcepub fn bind_value(self, path: impl Into<String>) -> Self
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}Sourcepub fn disabled(self, disabled: bool) -> Self
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more