Skip to main content

TextInput

Struct TextInput 

Source
pub struct TextInput { /* private fields */ }

Implementations§

Source§

impl TextInput

Source

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

Source§

fn type_name() -> &'static str

Returns full path to the widget type as a string. Read more
Source§

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

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

Creates a new widget. The common argument provides all available information about the context in which the widget is being created. Read more
Source§

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<()>

Handles a focus-out event. Read more
Source§

fn handle_layout(&mut self, event: LayoutEvent) -> Result<()>

Handles a layout event. Read more
Source§

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>

Calculates size hint of this widget along the X axis. Read more
Source§

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>

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>

Handles a request that asks for a certain area of a certain widget become visible. Read more
Source§

fn is_window_root_type() -> bool
where Self: Sized,

Returns true if this widget type is a window root. Read more
Source§

fn handle_draw(&mut self, event: DrawEvent) -> Result<()>

Handles a draw event. Read more
Source§

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>

Handles a mouse scroll wheel movement or a touchpad scroll gesture. Read more
Source§

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>

Handles a mouse move event. Read more
Source§

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<()>

Handles focus change of the OS window. Read more
Source§

fn handle_accessibility_action( &mut self, event: AccessibilityActionEvent, ) -> Result<()>

Handles an accessibility action. Read more
Source§

fn handle_event(&mut self, event: Event) -> Result<bool>

Source§

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>

Calculates size hint of this widget along the Y axis, given the X size. Read more
Source§

fn handle_accessibility_node_request(&mut self) -> Result<Option<Node>>

Calculates the accessibility node representing this widget. Read more

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
Source§

impl<W> WidgetExt for W
where W: Widget + ?Sized,

Source§

fn id(&self) -> WidgetId<Self>
where Self: Sized,

Source§

fn set_visible(&mut self, value: bool) -> &mut Self

Source§

fn set_focusable(&mut self, value: bool) -> &mut Self

Source§

fn set_accessibility_node_enabled(&mut self, value: bool) -> &mut Self

Source§

fn callback<F, E>(&self, func: F) -> Callback<E>
where F: Fn(&mut Self, E) -> Result<()> + 'static, E: 'static, Self: Sized,

Source§

fn dispatch(&mut self, event: Event) -> bool

Source§

fn scroll_to_rect(&mut self, request: ScrollToRectRequest) -> bool

Source§

fn update_accessibility_node(&mut self)

Source§

fn update_children(&mut self)

Source§

fn size_hint_x(&mut self) -> SizeHints

Source§

fn size_hint_y(&mut self, size_x: PhysicalPixels) -> SizeHints

Source§

fn add_class(&mut self, class: Cow<'static, str>) -> &mut Self

Source§

fn remove_class(&mut self, class: Cow<'static, str>) -> &mut Self

Source§

fn has_class(&self, class: &str) -> bool

Source§

fn set_class(&mut self, class: Cow<'static, str>, present: bool) -> &mut Self

Source§

fn add_pseudo_class(&mut self, class: PseudoClass) -> &mut Self

Source§

fn remove_pseudo_class(&mut self, class: PseudoClass) -> &mut Self

Source§

fn has_pseudo_class(&self, class: PseudoClass) -> bool

Source§

fn set_pseudo_class(&mut self, class: PseudoClass, present: bool) -> &mut Self

Source§

fn set_enabled(&mut self, enabled: bool) -> &mut Self

Source§

fn set_parent_enabled(&mut self, enabled: bool) -> &mut Self

Source§

fn set_scale(&mut self, scale: Option<f32>) -> &mut Self

Source§

fn set_row(&mut self, row: i32) -> &mut Self

Source§

fn set_column(&mut self, column: i32) -> &mut Self

Source§

fn set_size_x_fixed(&mut self, fixed: bool) -> &mut Self

Source§

fn set_size_y_fixed(&mut self, fixed: bool) -> &mut Self

Source§

fn set_geometry( &mut self, geometry: Option<WidgetGeometry>, changed_size_hints: &[WidgetAddress], )

Source§

fn boxed(self) -> Box<dyn Widget>
where Self: Sized,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more