Struct druid::text::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 copy 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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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.

§

impl<T> RoundFrom<T> for T

§

fn round_from(x: T) -> T

Performs the conversion.
§

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

§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · 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