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>
impl<T> EditSession<T>
sourcepub fn set_selection(&mut self, selection: Selection) -> Option<ImeInvalidation>
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
.
sourcepub fn composition_range(&self) -> Option<Range<usize>>
pub fn composition_range(&self) -> Option<Range<usize>>
The range of text currently being modified by an IME.
sourcepub fn set_accepts_newlines(&mut self, accepts_newlines: bool)
pub fn set_accepts_newlines(&mut self, accepts_newlines: bool)
Sets whether or not this session will allow the insertion of newlines.
sourcepub fn set_text_alignment(&mut self, alignment: TextAlignment)
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.
sourcepub fn text_alignment(&self) -> TextAlignment
pub fn text_alignment(&self) -> TextAlignment
The text alignment.
sourcepub fn pending_ime_invalidation(&mut self) -> Option<ImeInvalidation>
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>
impl<T: TextStorage + EditableText> EditSession<T>
sourcepub fn insert_text(&mut self, data: &mut T, new_text: &str) -> ImeInvalidation
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
.
sourcepub fn set_clipboard(&self) -> bool
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.)
sourcepub fn cursor_line_for_text_position(&self, pos: usize) -> Line
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>
impl<T: Clone> Clone for EditSession<T>
source§fn clone(&self) -> EditSession<T>
fn clone(&self) -> EditSession<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more