Skip to main content

EditText

Struct EditText 

Source
pub struct EditText {
Show 13 fields pub position: Rect, pub angle: Angle, pub text: String, pub align: Align2, pub font: Font, pub id: EditId, pub multiline: bool, pub char_limit: Option<usize>, pub tab_cycle: bool, pub select_all_on_focus: bool, pub hint: Option<&'static str>, pub colors: EditColors, pub wrap_width: Option<WorldPx>,
}
Expand description

What a tool asks for when it opens an in-place editor: where it sits in the world, what it opens on, and how the text is drawn. Passed to Canvas::set_edit_text; the host runs an editor of its own there and answers with how the edit ended, as a TextEvent.

Fields§

§position: Rect§angle: Angle

The field’s rotation about the centre of position.

§text: String

The text the editor opens on, as it stands in the document.

§align: Align2

Where the draft sits in position: the alignment of the label it replaces, so a right-aligned pin name is edited where it was drawn rather than at the far end of its field.

§font: Font§id: EditId§multiline: bool

When true the editor is multi-line: Enter inserts a newline (so it does not commit), and the edit is committed on focus loss instead.

§char_limit: Option<usize>

Maximum number of characters the editor accepts, or None for no limit. Caps short labels (pin names, titles, route labels) so an accidental paste can’t blow up the canvas layout; text boxes leave this None.

§tab_cycle: bool

This editor is a step in the block-edit Tab cycle (name, tag, and each pin’s name/type/tag). Such editors select all their text when they appear (so each step lands highlighted) and claim Tab/Escape from the host’s focus system so the cycle — not focus navigation — drives those keys.

§select_all_on_focus: bool

Select the whole buffer the first frame the editor appears, so typing replaces it. tab_cycle editors do this implicitly; this opts a non-cycle editor (e.g. the route label) into the same behavior without joining the Tab cycle.

§hint: Option<&'static str>

Placeholder shown while the buffer is empty (e.g. “Add Type”), or None.

§colors: EditColors

The colours the editor is painted in, resolved by the tool through its theme — an editor inside a block body takes the label’s ink and the body fill, so it blends with what it replaces.

§wrap_width: Option<WorldPx>

Word-wrap width for a multi-line editor (the text box), so the editor wraps at exactly the same width its rendered box does. None draws the text unwrapped (single-line editors never wrap).

Implementations§

Source§

impl EditText

Source

pub fn fitted(self, measure: &impl Renderer) -> Self

The request with its field sized once for every tool: room for the wider of the text and the hint as laid out — no narrower than the tool’s field or EDITOR_MIN_WIDTH, and a multi-line field no smaller than EDITOR_AREA_COLUMNS by EDITOR_AREA_LINES within its wrap — placed about the point align anchors, then the pad and the ring laid round it. The draft sits where the label was drawn, the field covers the label and no more of its neighbours than the pad, and no hint is cut short.

Trait Implementations§

Source§

impl Clone for EditText

Source§

fn clone(&self) -> EditText

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 Debug for EditText

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EditText

Source§

fn eq(&self, other: &EditText) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EditText

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more