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

Function handle_editor_escape

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

Source from the content-addressed store, hash-verified

613 true
614}
615
616pub fn handle_editor_escape<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
617 let action = with_state!(ctx.run, EditorState, ctx.id, |state| {
618 if state.command_palette_open {
619 "command_palette"
620 } else if state.inspector_picker_open {
621 "inspector_picker"
622 } else if state.add_node_popup_open {
623 "picker"
624 } else if state.anim_drawer_open {
625 "anim"
626 } else if state.sidebar_mode == "files"
627 && (!state.file_filter.is_empty() || !state.file_scope.is_empty())
628 {
629 "files"
630 } else if state.sidebar_mode == "scene" && !state.scene_filter.is_empty() {
631 "scene"
632 } else {
633 "none"
634 }
635 }).unwrap_or_default();
636 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
637 state.focused_inspector_box.clear();
638 });
639 match action {
640 "command_palette" => set_command_palette(ctx, false),
641 "inspector_picker" => set_inspector_picker(ctx, false),
642 "picker" => set_add_node_popup(ctx, false),
643 "anim" => set_anim_drawer(ctx, false),
644 "files" => {
645 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
646 state.file_filter.clear();
647 state.file_scope.clear();
648 state.log = "clear files filter".to_string();
649 });
650 refresh_all(ctx);
651 }
652 "scene" => {
653 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
654 state.scene_filter.clear();
655 state.log = "clear scene filter".to_string();
656 });
657 refresh_all(ctx);
658 }
659 _ => {
660 set_add_node_popup(ctx, false);
661 set_anim_drawer(ctx, false);
662 }
663 }

Callers 1

update_editor_shortcutsFunction · 0.85

Calls 4

set_inspector_pickerFunction · 0.85
set_add_node_popupFunction · 0.85
set_anim_drawerFunction · 0.85
refresh_allFunction · 0.85

Tested by

no test coverage detected