pub struct TextInput {Show 22 fields
pub asset_id: AssetId,
pub font: Option<FontHandle>,
pub content: String,
pub placeholder: String,
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub scale: f32,
pub text_color: [f32; 3],
pub placeholder_color: [f32; 3],
pub background: [f32; 4],
pub caret_color: [f32; 3],
pub corner_radius: f32,
pub padding: f32,
pub max_len: u32,
pub visible: bool,
pub fit: SpriteFit,
pub screen: Option<AssetId>,
pub focused: bool,
pub ghost: String,
pub caret: usize,
}Expand description
An editable single-line text field drawn as a UI overlay.
A filled rounded box showing the typed content (or a dimmer placeholder
while empty), plus a caret when the field holds keyboard focus. The engine
gives focus to the field the cursor clicks, appends the characters typed that
frame, and moves or edits at the caret with the arrow / Home / End /
Backspace / Delete keys. Read content back to use what the player typed;
set it to pre-fill the field.
Like other overlay elements it belongs to a Screen resolved from the
naming convention (<screen>_*), or is always shown when it has none.
TextInput {
placeholder: "Enter your name".into(),
x: 400.0,
y: 300.0,
width: 480.0,
height: 48.0,
max_len: 24,
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
font: Option<FontHandle>The Font used to render the field’s text. Unset draws with the engine’s built-in face at its native 24px.
content: StringThe current text. Edited in place as the player types; set an initial value here to pre-fill the field.
placeholder: StringDimmer prompt shown while content is empty and the field is unfocused.
x: f32Left edge in screen pixels from the window’s top-left.
y: f32Top edge in screen pixels from the window’s top-left.
width: f32Field width in screen pixels.
height: f32Field height in screen pixels.
scale: f32Uniform scale applied on top of the font’s size_px (24 for the
built-in face). 1.0 = native size.
text_color: [f32; 3]Linear-space RGB colour of the typed text.
placeholder_color: [f32; 3]Linear-space RGB colour of the placeholder prompt.
background: [f32; 4]RGBA fill of the field’s background box, each channel in [0, 1].
caret_color: [f32; 3]Linear-space RGB colour of the caret bar.
corner_radius: f32Corner rounding radius of the background box, in field pixels.
padding: f32Inner horizontal inset from the box edge to the text, in pixels.
max_len: u32Maximum number of characters accepted. 0 means no limit.
visible: boolWhen false the field is skipped each frame and cannot take focus.
fit: SpriteFitHow a screen-owned field maps from the reference canvas to the window when
their aspect ratios differ (matches Sprite’s fit).
screen: Option<AssetId>Screen this field belongs to. Resolved automatically from
the naming convention (<screen>_*); you don’t set this directly.
None means the field is always visible.
focused: boolRuntime keyboard-focus flag, set by the engine while this is the active field. Not authored and not serialized to a blob.
ghost: StringRuntime inline-completion suffix, drawn in the placeholder colour after the typed content while the field holds focus. Set by whoever drives the field (e.g. an autocomplete); never edited by typing. Not authored and not serialized to a blob.
caret: usizeRuntime caret position as a character index into content. Not authored
and not serialized to a blob.
Trait Implementations§
Source§impl Component for TextInput
impl Component for TextInput
Source§const NAME: &'static str = "TextInput"
const NAME: &'static str = "TextInput"
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<TextInput, CnResult>
fn from_baked(bytes: &[u8]) -> Result<TextInput, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for TextInput
impl ComponentSlot for TextInput
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§impl<'de> Deserialize<'de> for TextInput
impl<'de> Deserialize<'de> for TextInput
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextInput, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextInput, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<TextInput> for ComponentAsset
impl From<TextInput> for ComponentAsset
Source§fn from(c: TextInput) -> ComponentAsset
fn from(c: TextInput) -> ComponentAsset
impl RuntimeComponent for TextInput
Source§impl Serialize for TextInput
impl Serialize for TextInput
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for TextInput
impl RefUnwindSafe for TextInput
impl Send for TextInput
impl Sync for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
impl UnwindSafe for TextInput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().