Skip to content

Commit 7361b4a

Browse files
committed
doc: update documents
1 parent 085d1d6 commit 7361b4a

File tree

4 files changed

+59
-14
lines changed

4 files changed

+59
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [unreleased]
5+
## [0.4.0] - 2024-04-23
66

77
### Features
88

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy-input-sequence"
33
description = "Recognizes input sequences and send events"
4-
version = "0.3.0"
4+
version = "0.4.0"
55
edition = "2021"
66
authors = ["elm", "Shane Celis <shane.celis@gmail.com>"]
77
keywords = [

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,50 @@ fn check_events(mut events: EventReader<MyEvent>) {
132132
}
133133
```
134134

135+
## KeySequence creation patterns
136+
137+
`KeySequence::new` now returns an implementing of `Command` instead of itself.
138+
Therefore, you need to call `Commands::add` instead of `Commands::spawn`.
139+
140+
```rust
141+
use bevy::prelude::*;
142+
use bevy_input_sequence::prelude::*;
143+
144+
#[derive(Event, Clone)]
145+
struct MyEvent;
146+
147+
fn create_key_sequence(mut commands: Commands) {
148+
commands.add(KeySequence::new(
149+
action::send_event(bevy::app::AppExit),
150+
keyseq! { ctrl-E L M }
151+
));
152+
}
153+
154+
fn create_key_sequence_and_add_it_to_an_entity(mut commands: Commands) {
155+
let parent = commands.spawn_empty().id();
156+
commands.entity(parent).add(KeySequence::new(
157+
action::send_event(MyEvent),
158+
keyseq! { ctrl-E L M }
159+
));
160+
// OR
161+
commands.spawn_empty().add(KeySequence::new(
162+
action::send_event(MyEvent),
163+
keyseq! { ctrl-E L M }
164+
));
165+
}
166+
167+
fn create_key_sequence_within_command(mut commands: Commands) {
168+
commands.add(|world: &mut World| {
169+
let builder = KeySequence::new(
170+
action::send_event(MyEvent),
171+
keyseq! { ctrl-E L M }
172+
);
173+
let key_sequence = builder.build(world);
174+
// And then put it somewhere?
175+
});
176+
}
177+
```
178+
135179
# Runnable Examples
136180

137181
## keycode

src/lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.3.0")]
1+
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.4.0")]
22
#![doc = include_str!("../README.md")]
33
#![forbid(missing_docs)]
44

5+
pub use keyseq::{
6+
bevy::{pkey as key, pkeyseq as keyseq},
7+
Modifiers,
8+
};
9+
10+
pub use chord::KeyChord;
11+
pub use plugin::InputSequencePlugin;
12+
pub use time_limit::TimeLimit;
13+
514
pub mod action;
615
mod cache;
716
mod chord;
@@ -12,21 +21,13 @@ pub mod input_sequence;
1221
mod plugin;
1322
mod time_limit;
1423

15-
pub use keyseq::{
16-
bevy::{pkey as key, pkeyseq as keyseq},
17-
Modifiers,
18-
};
19-
2024
/// Convenient splat import
2125
pub mod prelude {
22-
pub use super::{action, keyseq, InputSequencePlugin, Modifiers, TimeLimit};
26+
pub use std::time::Duration;
27+
2328
pub use crate::input_sequence::{ButtonSequence, InputSequence, KeySequence};
2429

30+
pub use super::{action, InputSequencePlugin, keyseq, Modifiers, TimeLimit};
2531
pub use super::cond_system::IntoCondSystem;
26-
pub use std::time::Duration;
2732
}
2833

29-
pub use time_limit::TimeLimit;
30-
31-
pub use chord::KeyChord;
32-
pub use plugin::InputSequencePlugin;

0 commit comments

Comments
 (0)