|
| 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 | +
|
1 | 37 | use core::time::Duration;
|
2 | 38 |
|
3 | 39 | use alloc::collections::VecDeque;
|
@@ -37,6 +73,9 @@ use crate::{
|
37 | 73 | pub struct TextInputSystems;
|
38 | 74 |
|
39 | 75 | /// 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. |
40 | 79 | #[derive(Resource, Default)]
|
41 | 80 | pub struct Clipboard(pub String);
|
42 | 81 |
|
|
0 commit comments