Skip to main content

SecureTextEdit

Struct SecureTextEdit 

Source
pub struct SecureTextEdit<'a> { /* private fields */ }
Expand description

A widget for editing text.

This widget is identical to egui::TextEdit, but it uses a custom TextBuffer that can take either a [SecureString] or a String.

To use it with a [SecureString], the feature secure-types must be enabled.

§Notes

  • Accessability like screen readers is disabled to avoid multiple unsecure allocations of the entered text.
  • If you want to make sure the text you enter doesn’t stay in memory in any way you have to set Self::password to true.

Otherwise egui will make copies of that text and some of the copied allocations will stay in memory.

Implementations§

Source§

impl<'a> SecureTextEdit<'a>

Source

pub fn singleline(text: &'a mut dyn TextBuffer) -> Self

Single-line field. Enter is consumed (see Self::return_key).

Source

pub fn multiline(text: &'a mut dyn TextBuffer) -> Self

Multi-line field. Text wraps; Enter inserts a newline by default.

Source

pub fn visuals(self, visuals: TextEditVisuals) -> Self

Override the chrome that would otherwise come from the installed theme.

Source

pub fn id(self, id: Id) -> Self

Force a widget id (otherwise derived from the Ui id + salt).

Source

pub fn id_source(self, id_source: impl Hash + Debug) -> Self

Alias for Self::id_salt.

Source

pub fn id_salt(self, id_salt: impl Hash + Debug) -> Self

Extra id salt so two fields in the same Ui do not share state.

Source

pub fn hint_text(self, hint_text: impl Into<WidgetText>) -> Self

Placeholder shown when the buffer is empty.

Source

pub fn font(self, font_selection: impl Into<FontSelection>) -> Self

Font used to lay out the text.

Source

pub fn text_color(self, text_color: Color32) -> Self

Override the text color.

Source

pub fn text_color_opt(self, text_color: Option<Color32>) -> Self

Optional text color. None keeps the theme / style default.

Source

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

Mask glyphs and skip extra copies of the buffer.

Required if you want the entered text not to linger in egui allocations.

Source

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

Draw the framed background. Default: true.

Source

pub fn margin(self, margin: impl Into<Margin>) -> Self

Inner margin around the text.

Source

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

If false, the field is painted but ignores input.

Source

pub fn desired_width(self, desired_width: f32) -> Self

Preferred width. Defaults to egui::Spacing::text_edit_width.

Source

pub fn desired_rows(self, desired_height_rows: usize) -> Self

Preferred height, in rows of text (multiline).

Source

pub fn lock_focus(self, tab_will_indent: bool) -> Self

If true, Tab inserts a tab instead of moving focus.

Source

pub fn cursor_at_end(self, b: bool) -> Self

Place the cursor at the end when the field first gains focus.

Source

pub fn min_size(self, min_size: Vec2) -> Self

Minimum allocated size.

Source

pub fn horizontal_align(self, align: Align) -> Self

Horizontal alignment of the text inside the field.

Source

pub fn vertical_align(self, align: Align) -> Self

Vertical alignment of the text inside the field.

Source

pub fn clip_text(self, b: bool) -> Self

Clip overflowing text in single-line mode. Ignored for multiline.

Source

pub fn char_limit(self, limit: usize) -> Self

Maximum number of characters accepted.

Source

pub fn return_key(self, return_key: impl Into<Option<KeyboardShortcut>>) -> Self

Key that finishes editing on a single-line field. None disables it.

Source

pub fn background_color(self, color: Color32) -> Self

Override the background fill.

Source

pub fn show(self, ui: &mut Ui) -> SecureTextEditOutput

Paint the field and return the response plus updated cursor state.

Trait Implementations§

Source§

impl<'a> Widget for SecureTextEdit<'a>

Source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more
Source§

fn boxed<'a>(self) -> Box<dyn FnOnce(&mut Ui) -> Response + 'a>
where Self: Sized + 'a,

Box this widget for dynamic dispatch.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SecureTextEdit<'a>

§

impl<'a> !Send for SecureTextEdit<'a>

§

impl<'a> !Sync for SecureTextEdit<'a>

§

impl<'a> !UnwindSafe for SecureTextEdit<'a>

§

impl<'a> Freeze for SecureTextEdit<'a>

§

impl<'a> Unpin for SecureTextEdit<'a>

§

impl<'a> UnsafeUnpin for SecureTextEdit<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.