diff options
Diffstat (limited to 'src/entity_button.rs')
| -rw-r--r-- | src/entity_button.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/entity_button.rs b/src/entity_button.rs index baa89a4..35f787f 100644 --- a/src/entity_button.rs +++ b/src/entity_button.rs | |||
| @@ -36,6 +36,21 @@ impl<'a> Button<'a> { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | pub async fn pressed(&mut self) { | 38 | pub async fn pressed(&mut self) { |
| 39 | self.0.wait_command().await; | 39 | loop { |
| 40 | self.0.wait_command().await; | ||
| 41 | let pressed = self.0.with_data(|data| { | ||
| 42 | let storage = data.storage.as_button_mut(); | ||
| 43 | if !storage.consumed && storage.timestamp.is_some() { | ||
| 44 | storage.consumed = true; | ||
| 45 | true | ||
| 46 | } else { | ||
| 47 | false | ||
| 48 | } | ||
| 49 | }); | ||
| 50 | |||
| 51 | if pressed { | ||
| 52 | break; | ||
| 53 | } | ||
| 54 | } | ||
| 40 | } | 55 | } |
| 41 | } | 56 | } |
