Add Reflect derive to bevy_a11y::Focus (#14763)

Closes #14727
This commit is contained in:
callym 2024-08-15 18:33:20 +01:00 committed by GitHub
parent dbf0d7071e
commit 9d5837769c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -13,6 +13,7 @@ keywords = ["bevy", "accessibility", "a11y"]
bevy_app = { path = "../bevy_app", version = "0.15.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" }
accesskit = "0.16"

View file

@ -17,10 +17,11 @@ use accesskit::NodeBuilder;
use bevy_app::Plugin;
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
prelude::{Component, Entity, Event},
prelude::{Component, Entity, Event, ReflectResource},
schedule::SystemSet,
system::Resource,
};
use bevy_reflect::Reflect;
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
#[derive(Event, Deref, DerefMut)]
@ -92,7 +93,8 @@ impl From<NodeBuilder> for AccessibilityNode {
}
/// Resource representing which entity has keyboard focus, if any.
#[derive(Resource, Default, Deref, DerefMut)]
#[derive(Resource, Default, Deref, DerefMut, Reflect)]
#[reflect(Resource)]
pub struct Focus(pub Option<Entity>);
/// Set enum for the systems relating to accessibility
@ -108,6 +110,8 @@ pub struct AccessibilityPlugin;
impl Plugin for AccessibilityPlugin {
fn build(&self, app: &mut bevy_app::App) {
app.register_type::<Focus>();
app.init_resource::<AccessibilityRequested>()
.init_resource::<ManageAccessibilityUpdates>()
.init_resource::<Focus>()