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: AngleThe field’s rotation about the centre of position.
text: StringThe text the editor opens on, as it stands in the document.
align: Align2Where 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: boolWhen 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: boolThis 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: boolSelect 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: EditColorsThe 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
impl EditText
Sourcepub fn fitted(self, measure: &impl Renderer) -> Self
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.