[go: up one dir, main page]

EditSession

Struct EditSession 

Source
pub struct EditSession<T> {
    pub layout: TextLayout<T>,
    pub send_notification_on_return: bool,
    pub send_notification_on_cancel: bool,
    pub origin: Point,
    /* private fields */
}
Expand description

Editable text state.

This is the inner state of a TextComponent. It should only be accessed through its containing TextComponent, or by the platform through an ImeHandlerRef created by TextComponent::input_handler.

Fields§

§layout: TextLayout<T>

The inner TextLayout object.

This is exposed so that users can do things like set text properties; you should avoid doing things like rebuilding this layout manually, or setting the text directly.

§send_notification_on_return: bool

If true, the component will send the TextComponent::RETURN notification when the user enters a newline.

§send_notification_on_cancel: bool

If true, the component will send the TextComponent::CANCEL notification when the user cancels editing.

§origin: Point

The origin of the textbox, relative to the origin of the window.

Implementations§

Source§

impl<T> EditSession<T>

Source

pub fn selection(&self) -> Selection

The current Selection.

Source

pub fn set_selection(&mut self, selection: Selection) -> Option<ImeInvalidation>

Manually set the selection.

If the new selection is different from the current selection, this will return an ime event that the controlling widget should use to invalidte the platform’s IME state, by passing it to EventCtx::invalidate_text_input.

Source

pub fn composition_range(&self) -> Option<Range<usize>>

The range of text currently being modified by an IME.

Source

pub fn set_accepts_newlines(&mut self, accepts_newlines: bool)

Sets whether or not this session will allow the insertion of newlines.

Source

pub fn set_text_alignment(&mut self, alignment: TextAlignment)

Set the text alignment.

This is only meaningful for single-line text that does not fill the minimum layout size.

Source

pub fn text_alignment(&self) -> TextAlignment

The text alignment.

Source

pub fn pending_ime_invalidation(&mut self) -> Option<ImeInvalidation>

Returns any invalidation action that should be passed to the platform.

The user of this component must check this after calling update.

Source§

impl<T: TextStorage + EditableText> EditSession<T>

Source

pub fn insert_text(&mut self, data: &mut T, new_text: &str) -> ImeInvalidation

Insert text not from the IME, replacing the current selection.

The caller is responsible for notifying the platform of the change in text state, by calling EventCtx::invalidate_text_input.

Source

pub fn set_clipboard(&self) -> bool

Sets the clipboard to the contents of the current selection.

Returns true if the clipboard was set, and false if not (indicating) that the selection was empty.)

Source

pub fn cursor_line_for_text_position(&self, pos: usize) -> Line

Returns a line suitable for drawing a standard cursor.

Trait Implementations§

Source§

impl<T: Clone> Clone for EditSession<T>

Source§

fn clone(&self) -> EditSession<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for EditSession<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for EditSession<T>

§

impl<T> !RefUnwindSafe for EditSession<T>

§

impl<T> !Send for EditSession<T>

§

impl<T> !Sync for EditSession<T>

§

impl<T> Unpin for EditSession<T>
where T: Unpin,

§

impl<T> !UnwindSafe for EditSession<T>

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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