File size: 1,688 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;

namespace Unity.VisualScripting
{
    public abstract class NesterStateWidget<TNesterState> : StateWidget<TNesterState>
        where TNesterState : class, INesterState
    {
        protected NesterStateWidget(StateCanvas canvas, TNesterState state) : base(canvas, state) { }

        protected override IEnumerable<DropdownOption> contextOptions
        {
            get
            {
                var childReference = reference.ChildReference(state, false);

                if (state.childGraph != null)
                {
                    yield return new DropdownOption((Action)(() => window.reference = childReference), "Open");
                    yield return new DropdownOption((Action)(() => GraphWindow.OpenTab(childReference)), "Open in new window");
                }

                foreach (var baseOption in base.contextOptions)
                {
                    yield return baseOption;
                }
            }
        }

        protected override void OnDoubleClick()
        {
            if (state.graph.zoom == 1)
            {
                var childReference = reference.ChildReference(state, false);

                if (childReference != null)
                {
                    if (e.ctrlOrCmd)
                    {
                        GraphWindow.OpenTab(childReference);
                    }
                    else
                    {
                        window.reference = childReference;
                    }
                }

                e.Use();
            }
            else
            {
                base.OnDoubleClick();
            }
        }
    }
}