MCPcopy Create free account
hub / github.com/PerroEngine/Perro / open_sidebar_selection

Function open_sidebar_selection

perro_editor/res/scripts/scene/editor_nav.rs:1199–1226  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>)

Source from the content-addressed store, hash-verified

1197 }).unwrap_or_default();
1198 if let Some(idx) = idx {
1199 open_file_slot(ctx, idx);
1200 }
1201}
1202
1203pub fn open_sidebar_selection<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
1204 let mode = with_state!(ctx.run, EditorState, ctx.id, |state| {
1205 state.sidebar_mode.clone()
1206 }).unwrap_or_default();
1207 if mode == "files" {
1208 open_active_file(ctx);
1209 return;
1210 }
1211 let has_ref = with_state!(ctx.run, EditorState, ctx.id, |state| {
1212 let key = state.selected_key?;
1213 if state.doc_text.is_empty() {
1214 return None;
1215 }
1216 let doc = cached_scene_doc_shared(&state.doc_text);
1217 let node = doc
1218 .scene
1219 .nodes
1220 .iter()
1221 .find(|node| node.key.as_u32() == key)?;
1222 selected_node_asset_ref_path(node)
1223 }).unwrap_or_default()
1224 .is_some();
1225 if has_ref {
1226 open_selected_node_asset_ref(ctx);
1227 } else {
1228 frame_selected_node(ctx);
1229 }

Callers 1

update_editor_shortcutsFunction · 0.85

Calls 3

open_active_fileFunction · 0.85
frame_selected_nodeFunction · 0.85

Tested by

no test coverage detected