浏览代码

Fixed the shortcut problem in a proper way.

/main
Yuanxing Cai 7 年前
当前提交
a1e42ea7
共有 5 个文件被更改,包括 13 次插入13 次删除
  1. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  2. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs
  3. 17
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
  4. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  5. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs


public virtual GraphView CreateGraphView()
{
return new SerializableGraphView();
return new SerializableGraphView(this);
}
void OnEnable()

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs


m_CurrentControlPresenter = new List<GraphControlPresenter>();
usePixelCaching = false;
// Nodes need to be focusable to make the keyboard shortcuts work.
focusIndex = 0;
}
private void AddControls(GraphNodePresenter nodeData)

17
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs


// TODO JOCE Maybe bring SimpleGraphView public. This implements pretty much all that it does.
public class SerializableGraphView : GraphView
{
public SerializableGraphView()
private ShortcutHandler m_ShortcutHandler;
private EditorWindow m_EditorWindow;
public SerializableGraphView(EditorWindow editorWindow)
// Shortcut handler to delete elements
this.AddManipulator(new ShortcutHandler(
m_EditorWindow = editorWindow;
m_ShortcutHandler = new ShortcutHandler(
new Dictionary<Event, ShortcutDelegate>
{
{Event.KeyboardEvent("a"), FrameAll},

{Event.KeyboardEvent("#c"), CopySelection},
{Event.KeyboardEvent("#v"), Paste},
{Event.KeyboardEvent("#d"), DuplicateSelection}
}));
});
onEnter += () => m_EditorWindow.rootVisualContainer.parent.AddManipulator(m_ShortcutHandler);
onLeave += () => m_EditorWindow.rootVisualContainer.parent.RemoveManipulator(m_ShortcutHandler);
this.AddManipulator(new Commandable
{

Insert(0, new GridBackground());
typeFactory[typeof(GraphNodePresenter)] = typeof(NodeDrawer);
// Make this GraphView focusable or keyboard shortcuts won't work.
focusIndex = 0;
}
// TODO JOCE Remove the "new" here. Use the base class' impl

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


public override GraphView CreateGraphView()
{
return new MaterialGraphView();
return new MaterialGraphView(this);
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs


{
public class MaterialGraphView : SerializableGraphView
{
public MaterialGraphView()
public MaterialGraphView(EditorWindow editorWindow) : base(editorWindow)
{
RegisterCallback<MouseUpEvent>(DoContextMenu);

正在加载...
取消
保存