use crate::event::{EventResult, InputEvent, InputKey};
use crate::model::component_context::ComponentContext;
use crate::protocol::common_types::DynamicBoolean;
pub fn handle_event(ctx: &ComponentContext, event: &InputEvent) -> Option<EventResult> {
let InputEvent::KeyPress { key } = event;
if !matches!(key, InputKey::Enter | InputKey::Space) {
return None;
}
let comp_model = ctx.components.get(&ctx.component_id)?;
let value = comp_model.get_property::<DynamicBoolean>("value")?;
if let DynamicBoolean::Binding(binding) = value {
return Some(EventResult::Toggle { path: binding.path });
}
None
}