fix(script): deselect individual properties via Property.selected=false (#548)

This commit is contained in:
Nigel Ihza Firdausy
2026-10-10 15:58:22 +07:00
parent 813c7c4650
commit 4bc619b010
3 changed files with 46 additions and 1 deletions
+14
View File
@@ -346,6 +346,19 @@ fn select_prop(s: &mut Session, p: &Value) -> Result<Value> {
Ok(Value::Null)
}
/// Deselect only the named property, preserving unrelated property, layer, key and
/// mask-vertex selections. Selected keys also imply selectedProperties in the script API.
fn deselect_prop(s: &mut Session, params: &Value) -> Result<Value> {
let (_, lid, uid) = prop_ref(s, params, "prop.deselect")?;
let mask = s.active_comp().and_then(|c| c.layer(lid)).and_then(|l| path_points(l, uid, l.layer_time(s.time()))).map(|(mask, _)| mask);
s.state.selected_props.retain(|(layer, prop)| *layer != lid || *prop != uid);
s.state.selected_keys.retain(|key| key.layer != lid || key.prop != uid);
if let Some(mask) = mask {
s.state.selected_vertices.retain(|v| v.layer != lid || v.mask != mask);
}
Ok(Value::Null)
}
/// The mask or shape Path item that `uid` (the group, or its Path property) is, with its number
/// of points at layer time `lt`.
fn path_points(l: &Layer, uid: Uid, lt: Tick) -> Option<(Uid, usize)> {
@@ -820,6 +833,7 @@ pub fn specs() -> Vec<CommandSpec> {
reset
),
cmd!("prop.select", "Select Property", [], None, "{layer?, path|prop, add?, selectKeys?}", has_layers, select_prop),
cmd!("prop.deselect", "Deselect Property", [], None, "{layer?, path|prop}", has_layers, deselect_prop),
cmd!(
"prop.convertExpressionToKeyframes",
"Convert Expression to Keyframes",