Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ickshonpe/bevy_ui_text_cursor
bevy ui text cursor
https://github.com/ickshonpe/bevy_ui_text_cursor
bevy ui
Last synced: about 1 month ago
JSON representation
bevy ui text cursor
- Host: GitHub
- URL: https://github.com/ickshonpe/bevy_ui_text_cursor
- Owner: ickshonpe
- License: mit
- Created: 2022-06-20T22:48:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-21T08:56:34.000Z (over 2 years ago)
- Last Synced: 2023-03-04T15:37:18.438Z (almost 2 years ago)
- Topics: bevy, ui
- Language: Rust
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bevy Ui Text Cursor
text cursor for bevy_ui
supports Bevy 0.7
## Usage
Add the plugin to your app
```rust
app.add_plugin(bevy_ui_text_cursor::BevyUiTextCursorPlugin)
```Then you can spawn a text bundle with a cursor like so:
```rust
commands.spawn_bundle(
TextBundle {
text: Text {
sections: vec![
TextSection {
value: "Hello, World".to_string(),
style: TextStyle {
font: asset_server.load("FiraMono-Medium.ttf"),
font_size: 32.0,
color: Color::WHITE,
}
},
],
alignment: TextAlignment { vertical: VerticalAlign::Center, horizontal:HorizontalAlign::Center },
..Default::default()
},
..Default::default()
}
)
.insert(UiTextCursor::default())
.insert(UiTextCursorStyle::default());
```And it will draw a cursor over the H.
UiTextCursor is just a newtype containing a usize.
If UiTextCursor contains N then the cursor will be drawn over the Nth glyph in the Text component.
There is also a ```UiTextCursorBlink``` component you can add to get a blinking cursor.## Examples
```
cargo run --example hello_world
```which displays the message "Hello, World" and a cursor you can move left and right with the left and right arrow keys.
## Notes
Very rough work in progress. Many problems.