Skip to content

Commit 66048df

Browse files
Initial module docs
1 parent cb9aa00 commit 66048df

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

crates/bevy_text/src/input.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
//! This module provides text editing functionality, by wrapping the functionality of the
2+
//! [`cosmic_text`] crate.
3+
//!
4+
//! The primary entry point into the text editing functionality is the [`TextInputBuffer`] component,
5+
//! which includes a [`cosmic_text::Editor`], and adds the associated "required components" needed
6+
//! to construct functioning text input fields.
7+
//!
8+
//! ## How this works
9+
//!
10+
//! Text editing functionality is included as part of [`TextPlugin`](crate::TextPlugin),
11+
//! and the systems which perform the work are grouped under the [`TextInputSystems`] system set.
12+
//!
13+
//! The [`TextInputBuffer`] comes with the following required components that act as machinery to convert user inputs into text:
14+
//!
15+
//! * [`TextInputValue`] - Contains the current text in the text input buffer.
16+
//! * Automatically synchronized with the buffer by [`apply_text_edits`] after any edits are applied.
17+
//! * [`TextEdits`] - Text input commands queue, used to queue up text edit and navigation actions.\
18+
//! * Contains a queue of [`TextEdit`] actions that are applied to the buffer.
19+
//! * These are applied by the [`apply_text_edits` system.
20+
//! * [`TextInputTarget`] - Details of the render target the text input will be rendered to, such as size and scale factor.
21+
//!
22+
//! ## Configuring text input
23+
//!
24+
//! Several components are used to configure the text input, and belong on the [`TextInputBuffer`] entity:
25+
//!
26+
//! * [`TextInputAttributes`] - Common text input properties set by the user, such as font, font size, line height, justification, maximum characters etc.
27+
//! * [`TextInputFilter`] - Optional component that can be added to restrict the text input to certain formats, such as integers, decimals, hexadecimal etc.
28+
//! * [`PasswordMask`] - Optional component that can be added to hide the text input buffer contents by replacing the characters with a mask character.
29+
//!
30+
//! ## Copy-paste and clipboard support
31+
//!
32+
//! The clipboard support provided by this module is very basic, and only works within the `bevy` app,
33+
//! storing a simple [`String`].
34+
//!
35+
//! It can be accessed via the [`Clipboard`] resource.
36+
137
use core::time::Duration;
238

339
use alloc::collections::VecDeque;
@@ -37,6 +73,9 @@ use crate::{
3773
pub struct TextInputSystems;
3874

3975
/// Basic clipboard implementation that only works within the bevy app.
76+
///
77+
/// This is written to in the [`apply_text_edits`] system when
78+
/// [`TextEdit::Copy`], [`TextEdit::Cut`] or [`TextEdit::Paste`] edits are applied.
4079
#[derive(Resource, Default)]
4180
pub struct Clipboard(pub String);
4281

crates/bevy_text/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This crate provides the tools for positioning and rendering text in Bevy.
1+
//! This crate provides the tools for positioning, rendering and editing text in Bevy.
22
//!
33
//! # `Font`
44
//!
@@ -28,6 +28,10 @@
2828
//! retrieving glyphs from the cache, or rasterizing to a [`FontAtlas`] if necessary.
2929
//! 3. [`PositionedGlyph`]s are stored in a [`TextLayoutInfo`],
3030
//! which contains all the information that downstream systems need for rendering.
31+
//!
32+
//! ## Text editing
33+
//!
34+
//! See the [`input`] module for more details on text editing support.
3135
3236
extern crate alloc;
3337

0 commit comments

Comments
 (0)