pub struct TextInput { /* private fields */ }Implementations§
Source§impl TextInput
impl TextInput
Sourcepub fn set_text(&mut self, text: impl Display)
pub fn set_text(&mut self, text: impl Display)
Examples found in repository?
examples/start.rs (line 130)
115 fn new(mut base: WidgetBaseOf<Self>) -> Self {
116 let id = base.id();
117
118 let window = base.add_child::<Window>().set_title("example");
119
120 let root = window
121 .base_mut()
122 .add_child::<Column>()
123 .set_column(0)
124 .set_row(0);
125
126 root.base_mut()
127 .add_child::<TextInput>()
128 .set_column(0)
129 .set_row(0)
130 .set_text("Hello, Rust! 🦀😂\n");
131 root.base_mut()
132 .add_child::<TextInput>()
133 .set_column(0)
134 .set_row(1)
135 .set_text("Hebrew name Sarah: שרה.");
136
137 /*
138 let btn = Button::new("btn1")
139 .with_icon(icon)
140 .with_alignment(Al::Right)
141 .with_on_clicked(slot)
142 .split_id()
143 .boxed();
144 root.add(btn.widget);
145
146 Self {
147 btn_id: btn.id,
148 }
149
150
151 */
152
153 let button_id = root
154 .base_mut()
155 .add_child::<Button>()
156 .set_column(0)
157 .set_row(2)
158 .set_text("btn1")
159 .set_auto_repeat(true)
160 .on_triggered(id.callback(|this, event| this.button_clicked(event, 1)))
161 .id();
162
163 root.base_mut()
164 .add_child::<Button>()
165 .set_column(0)
166 .set_row(3)
167 .set_text("btn2")
168 .on_triggered(id.callback(|this, event| this.button_clicked(event, 2)));
169
170 let column2 = root
171 .base_mut()
172 .add_child::<Column>()
173 .set_column(0)
174 .set_row(4);
175 let button21_id = column2
176 .base_mut()
177 .add_child::<Button>()
178 .set_column(0)
179 .set_row(0)
180 .set_text("btn21")
181 .on_triggered(id.callback(|_, _| {
182 println!("click!");
183 Ok(())
184 }))
185 .id();
186
187 let button22_id = column2
188 .base_mut()
189 .add_child::<Button>()
190 .set_column(0)
191 .set_row(1)
192 .set_text("btn22")
193 .id();
194 let column2_id = column2.id();
195
196 root.base_mut()
197 .add_child::<AnotherWidget>()
198 .set_column(0)
199 .set_row(5);
200
201 let label2_id = root
202 .base_mut()
203 .add_child::<Label>()
204 .set_column(0)
205 .set_row(6)
206 .set_text("ok")
207 .id();
208
209 let scroll_area = root
210 .base_mut()
211 .add_child::<ScrollArea>()
212 .set_column(0)
213 .set_row(7);
214 let content = scroll_area.set_content::<Column>();
215 for i in 1..=80 {
216 content
217 .base_mut()
218 .add_child::<Button>()
219 .set_column(0)
220 .set_row(i)
221 .set_text(format!("btn btn btn btn btn btn btn btn btn btn{i}"));
222 }
223
224 add_interval(Duration::from_secs(2), id.callback(|this, _| this.inc()));
225
226 RootWidget {
227 base,
228 button_id,
229 column2_id,
230 button21_id,
231 button22_id,
232 flag_column: true,
233 flag_button21: true,
234 i: 0,
235 label2_id,
236 }
237 }Trait Implementations§
Source§impl Widget for TextInput
impl Widget for TextInput
Source§fn base(&self) -> &WidgetBase
fn base(&self) -> &WidgetBase
Returns a non-unique, read-only reference to
WidgetCommon object stored inside the widget.
It’s recommended to use impl_widget_common! macro
to automatically implement this function.Source§fn base_mut(&mut self) -> &mut WidgetBase
fn base_mut(&mut self) -> &mut WidgetBase
Returns a unique, read-write reference to
WidgetCommon object stored inside the widget.
It’s recommended to use impl_widget_common! macro
to automatically implement this function.Source§fn new(base: WidgetBaseOf<Self>) -> Self
fn new(base: WidgetBaseOf<Self>) -> Self
Creates a new widget. The
common argument provides all available information about the context in which
the widget is being created. Read moreSource§fn handle_focus_in(&mut self, event: FocusInEvent) -> Result<()>
fn handle_focus_in(&mut self, event: FocusInEvent) -> Result<()>
Handles a focus-in event. Read more
Source§fn handle_focus_out(&mut self, _event: FocusOutEvent) -> Result<()>
fn handle_focus_out(&mut self, _event: FocusOutEvent) -> Result<()>
Handles a focus-out event. Read more
Source§fn handle_layout(&mut self, event: LayoutEvent) -> Result<()>
fn handle_layout(&mut self, event: LayoutEvent) -> Result<()>
Handles a layout event. Read more
Source§fn handle_style_change(&mut self, _event: StyleChangeEvent) -> Result<()>
fn handle_style_change(&mut self, _event: StyleChangeEvent) -> Result<()>
Handles a style change. Read more
Source§fn handle_size_hint_x_request(&mut self) -> Result<SizeHints>
fn handle_size_hint_x_request(&mut self) -> Result<SizeHints>
Calculates size hint of this widget along the X axis. Read more
Source§fn handle_keyboard_input(&mut self, event: KeyboardInputEvent) -> Result<bool>
fn handle_keyboard_input(&mut self, event: KeyboardInputEvent) -> Result<bool>
Handles a press or release of a keyboard button. Read more
Source§fn handle_input_method(&mut self, event: InputMethodEvent) -> Result<bool>
fn handle_input_method(&mut self, event: InputMethodEvent) -> Result<bool>
Handles an event from the input method (IME) provided by the OS. Read more
Source§fn handle_scroll_to_rect_request(
&mut self,
event: ScrollToRectRequest,
) -> Result<bool>
fn handle_scroll_to_rect_request( &mut self, event: ScrollToRectRequest, ) -> Result<bool>
Handles a request that asks for a certain area of a certain widget become visible. Read more
Source§fn is_window_root_type() -> boolwhere
Self: Sized,
fn is_window_root_type() -> boolwhere
Self: Sized,
Returns true if this widget type is a window root. Read more
Source§fn handle_mouse_input(&mut self, event: MouseInputEvent) -> Result<bool>
fn handle_mouse_input(&mut self, event: MouseInputEvent) -> Result<bool>
Handles a press or release of a mouse button. Read more
Source§fn handle_mouse_scroll(&mut self, event: MouseScrollEvent) -> Result<bool>
fn handle_mouse_scroll(&mut self, event: MouseScrollEvent) -> Result<bool>
Handles a mouse scroll wheel movement or a touchpad scroll gesture. Read more
Source§fn handle_mouse_enter(&mut self, event: MouseEnterEvent) -> Result<bool>
fn handle_mouse_enter(&mut self, event: MouseEnterEvent) -> Result<bool>
Handles a mouse enter event. Read more
Source§fn handle_mouse_move(&mut self, event: MouseMoveEvent) -> Result<bool>
fn handle_mouse_move(&mut self, event: MouseMoveEvent) -> Result<bool>
Handles a mouse move event. Read more
Source§fn handle_mouse_leave(&mut self, event: MouseLeaveEvent) -> Result<()>
fn handle_mouse_leave(&mut self, event: MouseLeaveEvent) -> Result<()>
Handles a mouse leave event. Read more
Source§fn handle_window_focus_change(
&mut self,
event: WindowFocusChangeEvent,
) -> Result<()>
fn handle_window_focus_change( &mut self, event: WindowFocusChangeEvent, ) -> Result<()>
Handles focus change of the OS window. Read more
Source§fn handle_accessibility_action(
&mut self,
event: AccessibilityActionEvent,
) -> Result<()>
fn handle_accessibility_action( &mut self, event: AccessibilityActionEvent, ) -> Result<()>
Handles an accessibility action. Read more
fn handle_event(&mut self, event: Event) -> Result<bool>
Source§fn handle_declare_children_request(&mut self) -> Result<()>
fn handle_declare_children_request(&mut self) -> Result<()>
Updates state of the widget’s children. Read more
Source§fn handle_size_hint_y_request(
&mut self,
size_x: PhysicalPixels,
) -> Result<SizeHints>
fn handle_size_hint_y_request( &mut self, size_x: PhysicalPixels, ) -> Result<SizeHints>
Calculates size hint of this widget along the Y axis, given the X size. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TextInput
impl !Send for TextInput
impl !Sync for TextInput
impl !UnwindSafe for TextInput
impl Freeze for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more