blob: 0638b01b6098357b5e12c2a2857ae33864badd71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use bevy::prelude::*;
use crate::input::events::TerminalInputEvent;
use super::components::Widget;
/// Invokes every enabled widget's `handle_events` methods for each incoming input event
pub fn widget_input_handling(
mut widgets: Query<&mut Widget>,
mut event_reader: EventReader<TerminalInputEvent>,
mut commands: Commands,
) {
for event in event_reader.read() {
for mut widget in widgets.iter_mut().filter(|widget| widget.enabled) {
widget.widget.handle_events(event, &mut commands);
}
}
}
pub fn update_widgets(mut widgets: Query<&mut Widget>, time: Res<Time>, mut commands: Commands) {
for mut widget in widgets.iter_mut() {
widget.widget.update(&time, &mut commands);
}
}
|