pub struct TextInput {Show 33 fields
pub text: Property<SharedString>,
pub font_family: Property<SharedString>,
pub font_size: Property<LogicalLength>,
pub font_weight: Property<i32>,
pub font_italic: Property<bool>,
pub color: Property<Brush>,
pub selection_foreground_color: Property<Color>,
pub selection_background_color: Property<Color>,
pub horizontal_alignment: Property<TextHorizontalAlignment>,
pub vertical_alignment: Property<TextVerticalAlignment>,
pub wrap: Property<TextWrap>,
pub input_type: Property<InputType>,
pub input_method_hints: Property<InputMethodHints>,
pub letter_spacing: Property<LogicalLength>,
pub line_height_factor: Property<f32>,
pub width: Property<LogicalLength>,
pub height: Property<LogicalLength>,
pub cursor_position_byte_offset: Property<i32>,
pub anchor_position_byte_offset: Property<i32>,
pub text_cursor_width: Property<LogicalLength>,
pub page_height: Property<LogicalLength>,
pub cursor_visible: Property<bool>,
pub has_focus: Property<bool>,
pub enabled: Property<bool>,
pub accepted: Callback<VoidArg>,
pub cursor_position_changed: Callback<(LogicalPosition,)>,
pub edited: Callback<VoidArg>,
pub key_pressed: Callback<KeyEventArg, EventResult>,
pub key_released: Callback<KeyEventArg, EventResult>,
pub single_line: Property<bool>,
pub read_only: Property<bool>,
pub preedit_text: Property<SharedString>,
pub cached_rendering_data: CachedRenderingData,
/* private fields */
}Expand description
The implementation of the TextInput element
Fields§
§text: Property<SharedString>§font_family: Property<SharedString>§font_size: Property<LogicalLength>§font_weight: Property<i32>§font_italic: Property<bool>§color: Property<Brush>§selection_foreground_color: Property<Color>§selection_background_color: Property<Color>§horizontal_alignment: Property<TextHorizontalAlignment>§vertical_alignment: Property<TextVerticalAlignment>§wrap: Property<TextWrap>§input_type: Property<InputType>§input_method_hints: Property<InputMethodHints>§letter_spacing: Property<LogicalLength>§line_height_factor: Property<f32>§width: Property<LogicalLength>§height: Property<LogicalLength>§cursor_position_byte_offset: Property<i32>§anchor_position_byte_offset: Property<i32>§text_cursor_width: Property<LogicalLength>§page_height: Property<LogicalLength>§cursor_visible: Property<bool>§has_focus: Property<bool>§enabled: Property<bool>§accepted: Callback<VoidArg>§cursor_position_changed: Callback<(LogicalPosition,)>§edited: Callback<VoidArg>§key_pressed: Callback<KeyEventArg, EventResult>§key_released: Callback<KeyEventArg, EventResult>§single_line: Property<bool>§read_only: Property<bool>§preedit_text: Property<SharedString>§cached_rendering_data: CachedRenderingDataImplementations§
Source§impl TextInput
impl TextInput
Sourcepub const FIELD_OFFSETS: TextInputFieldsOffsets = TextInputFieldsOffsets
pub const FIELD_OFFSETS: TextInputFieldsOffsets = TextInputFieldsOffsets
Return a zero-sized helper whose methods return field offsets.
Source§impl TextInput
impl TextInput
pub fn text(self: Pin<&Self>) -> SharedString
pub fn font_family(self: Pin<&Self>) -> SharedString
pub fn font_size(self: Pin<&Self>) -> LogicalLength
pub fn font_weight(self: Pin<&Self>) -> i32
pub fn font_italic(self: Pin<&Self>) -> bool
pub fn color(self: Pin<&Self>) -> Brush
pub fn selection_foreground_color(self: Pin<&Self>) -> Color
pub fn selection_background_color(self: Pin<&Self>) -> Color
pub fn horizontal_alignment(self: Pin<&Self>) -> TextHorizontalAlignment
pub fn vertical_alignment(self: Pin<&Self>) -> TextVerticalAlignment
pub fn wrap(self: Pin<&Self>) -> TextWrap
pub fn input_type(self: Pin<&Self>) -> InputType
pub fn input_method_hints(self: Pin<&Self>) -> InputMethodHints
pub fn letter_spacing(self: Pin<&Self>) -> LogicalLength
pub fn line_height_factor(self: Pin<&Self>) -> f32
pub fn width(self: Pin<&Self>) -> LogicalLength
pub fn height(self: Pin<&Self>) -> LogicalLength
pub fn cursor_position_byte_offset(self: Pin<&Self>) -> i32
pub fn anchor_position_byte_offset(self: Pin<&Self>) -> i32
pub fn text_cursor_width(self: Pin<&Self>) -> LogicalLength
pub fn page_height(self: Pin<&Self>) -> LogicalLength
pub fn cursor_visible(self: Pin<&Self>) -> bool
pub fn has_focus(self: Pin<&Self>) -> bool
pub fn enabled(self: Pin<&Self>) -> bool
pub fn single_line(self: Pin<&Self>) -> bool
pub fn read_only(self: Pin<&Self>) -> bool
pub fn preedit_text(self: Pin<&Self>) -> SharedString
Source§impl TextInput
impl TextInput
Sourcepub fn set_cursor_position(
self: Pin<&Self>,
new_position: i32,
reset_preferred_x_pos: bool,
trigger_callbacks: TextChangeNotify,
window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &ItemRc,
)
pub fn set_cursor_position( self: Pin<&Self>, new_position: i32, reset_preferred_x_pos: bool, trigger_callbacks: TextChangeNotify, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
Places the cursor at a text position (next-character affinity at a soft line break). Use
Self::set_cursor_position_with_affinity for a position that came from a visual location.
pub fn set_cursor_position_with_affinity( self: Pin<&Self>, new_position: i32, affinity: TextCursorAffinity, reset_preferred_x_pos: bool, trigger_callbacks: TextChangeNotify, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn delete_selection( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, trigger_callbacks: TextChangeNotify, )
pub fn anchor_position(self: Pin<&Self>, text: &str) -> usize
Sourcepub fn is_password(self: Pin<&Self>) -> bool
pub fn is_password(self: Pin<&Self>) -> bool
Whether this input masks what is typed into it.
pub fn cursor_position(self: Pin<&Self>, text: &str) -> usize
Sourcepub fn cursor_position_affinity(self: Pin<&Self>) -> TextCursorAffinity
pub fn cursor_position_affinity(self: Pin<&Self>) -> TextCursorAffinity
Which of the two visual positions the cursor byte offset means, for an offset that sits at a soft line break.
pub fn selection_anchor_and_cursor(self: Pin<&Self>) -> (usize, usize)
pub fn has_selection(self: Pin<&Self>) -> bool
pub fn cut( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn set_selection_offsets( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, anchor: i32, focus: i32, )
pub fn select_all( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn clear_selection(self: Pin<&Self>, _: &Rc<dyn WindowAdapter>, _: &ItemRc)
pub fn select_word( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn copy(self: Pin<&Self>, w: &Rc<dyn WindowAdapter>, _: &ItemRc)
pub fn paste( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
Sourcepub fn visual_representation(self: Pin<&Self>) -> TextInputVisualRepresentation
pub fn visual_representation(self: Pin<&Self>) -> TextInputVisualRepresentation
Returns a TextInputVisualRepresentation struct that contains all the fields necessary for rendering the text input,
after making adjustments such as applying a substitution of characters for password input fields, or making sure
that the selection start is always less or equal than the selection end.
pub fn byte_offset_for_position( self: Pin<&Self>, pos: LogicalPoint, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, ) -> (usize, TextCursorAffinity)
pub fn undo( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn redo( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, )
pub fn font_metrics( self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, ) -> FontMetrics
Trait Implementations§
Source§impl HasFont for TextInput
impl HasFont for TextInput
fn font_request(self: Pin<&Self>, self_rc: &ItemRc) -> FontRequest
Source§impl HasStaticVTable<ItemVTable> for TextInput
impl HasStaticVTable<ItemVTable> for TextInput
Source§const STATIC_VTABLE: &'static ItemVTable
const STATIC_VTABLE: &'static ItemVTable
Safety: must point to the single static VTable for Self. Downcasts
compare vtables by address, so it must not be a promoted temporary.
Source§impl Item for TextInput
impl Item for TextInput
Source§fn init(self: Pin<&Self>, self_rc: &ItemRc)
fn init(self: Pin<&Self>, self_rc: &ItemRc)
This function is called by the run-time after the memory for the item
has been allocated and initialized. It will be called before any user specified
bindings are set.
fn deinit(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>)
Source§fn layout_info(
self: Pin<&Self>,
orientation: Orientation,
cross_axis_constraint: Coord,
window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &ItemRc,
) -> LayoutInfo
fn layout_info( self: Pin<&Self>, orientation: Orientation, cross_axis_constraint: Coord, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, ) -> LayoutInfo
We would need max/min/preferred size, and all layout info.
cross_axis_constraint is the available width when querying vertical
layout info, enabling height-for-width (Text word-wrap, Image aspect
ratio). Negative values mean unconstrained.Source§fn input_event_filter_before_children(
self: Pin<&Self>,
_: &MouseEvent,
_window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc,
_: &mut MouseCursorInner,
) -> InputEventFilterResult
fn input_event_filter_before_children( self: Pin<&Self>, _: &MouseEvent, _window_adapter: &Rc<dyn WindowAdapter>, _self_rc: &ItemRc, _: &mut MouseCursorInner, ) -> InputEventFilterResult
Event handler for mouse and touch event. This function is called before being called on children.
Then, depending on the return value, it is called for the children, and their children, then
Self::input_event is called on the children, and finally Self::input_event is called
on this item again. Read moreSource§fn input_event(
self: Pin<&Self>,
event: &MouseEvent,
window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &ItemRc,
cursor: &mut MouseCursorInner,
) -> InputEventResult
fn input_event( self: Pin<&Self>, event: &MouseEvent, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, cursor: &mut MouseCursorInner, ) -> InputEventResult
Handle input event for mouse and touch event
Source§fn capture_key_event(
self: Pin<&Self>,
_: &InternalKeyEvent,
_window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc,
) -> KeyEventResult
fn capture_key_event( self: Pin<&Self>, _: &InternalKeyEvent, _window_adapter: &Rc<dyn WindowAdapter>, _self_rc: &ItemRc, ) -> KeyEventResult
Called on the parents of the focused item, allowing for global shortcuts and similar
overrides of the default actions.
fn key_event( self: Pin<&Self>, event: &InternalKeyEvent, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, ) -> KeyEventResult
fn focus_event( self: Pin<&Self>, event: &FocusEvent, window_adapter: &Rc<dyn WindowAdapter>, self_rc: &ItemRc, ) -> FocusEventResult
fn render( self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer, self_rc: &ItemRc, size: LogicalSize, ) -> RenderingResult
Source§fn bounding_rect(
self: Pin<&Self>,
_window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc,
geometry: LogicalRect,
) -> LogicalRect
fn bounding_rect( self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>, _self_rc: &ItemRc, geometry: LogicalRect, ) -> LogicalRect
Returns the rendering bounding rect for that particular item in the parent’s item coordinate
(same coordinate system as the geometry)
fn clips_children(self: Pin<&Self>) -> bool
Source§impl ItemConsts for TextInput
impl ItemConsts for TextInput
Source§const cached_rendering_data_offset: FieldOffset<TextInput, CachedRenderingData>
const cached_rendering_data_offset: FieldOffset<TextInput, CachedRenderingData>
offset in bytes from the *const ItemImpl.
usize::MAX means None
Source§impl RenderString for TextInput
impl RenderString for TextInput
fn text(self: Pin<&Self>) -> PlainOrStyledText
fn max_lines(self: Pin<&Self>) -> i32
Source§fn line_limit(self: Pin<&Self>) -> Option<usize>
fn line_limit(self: Pin<&Self>) -> Option<usize>
The maximum number of lines to lay out and render, from the
max-lines property.
Property values less than or equal to zero mean no limit.Source§fn stroke(self: Pin<&Self>) -> (Brush, LogicalLength, TextStrokeStyle)
fn stroke(self: Pin<&Self>) -> (Brush, LogicalLength, TextStrokeStyle)
Stroke brush, width and style. The style is baked into the shaped glyphs, so it lives
here (rather than in
RenderText) to keep measuring and drawing shaping-identical.Source§fn link_color(self: Pin<&Self>) -> Color
fn link_color(self: Pin<&Self>) -> Color
Color of
Style::Link spans. Like stroke, it’s baked into the shaped glyphs.impl<'__dummy_lifetime> Unpin for TextInputwhere
__MustNotImplUnpin<'__dummy_lifetime>: Unpin,
Auto Trait Implementations§
impl !Freeze for TextInput
impl !RefUnwindSafe for TextInput
impl !Send for TextInput
impl !Sync for TextInput
impl !UnsafeUnpin for TextInput
impl !UnwindSafe for TextInput
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