浏览代码

#43 Handle keyboard shortcuts in window rather than GraphView

/main
Peter Bay Bastian 7 年前
当前提交
d465f37d
共有 2 个文件被更改,包括 14 次插入13 次删除
  1. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  2. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


if (e.commandName == "Delete" || e.commandName == "SoftDelete")
presenter.Delete();
}
if (e.type == EventType.KeyDown)
{
if (e.keyCode == KeyCode.A)
m_GraphEditorView.graphView.FrameAll();
if (e.keyCode == KeyCode.F)
m_GraphEditorView.graphView.FrameSelection();
if (e.keyCode == KeyCode.O)
m_GraphEditorView.graphView.FrameOrigin();
if (e.keyCode == KeyCode.Tab)
m_GraphEditorView.graphView.FrameNext();
if (e.keyCode == KeyCode.Tab && e.modifiers == EventModifiers.Shift)
m_GraphEditorView.graphView.FramePrev();
}
}
public void PingAsset()

13
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


public MaterialGraphView(EditorWindow editorWindow)
{
var shortcutHandler = new ShortcutHandler(
new Dictionary<Event, ShortcutDelegate>
{
{Event.KeyboardEvent("a"), FrameAll},
{Event.KeyboardEvent("f"), FrameSelection},
{Event.KeyboardEvent("o"), FrameOrigin},
{Event.KeyboardEvent("#tab"), FramePrev},
{Event.KeyboardEvent("tab"), FrameNext}
});
onEnter += () => editorWindow.rootVisualContainer.parent.AddManipulator(shortcutHandler);
onLeave += () => editorWindow.rootVisualContainer.parent.RemoveManipulator(shortcutHandler);
this.AddManipulator(new ContentZoomer());
this.AddManipulator(new ContentDragger());
this.AddManipulator(new RectangleSelector());

正在加载...
取消
保存