MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnKeyDown

Method OnKeyDown

Source/Editor/Content/GUI/ContentView.cs:748–806  ·  view source on GitHub ↗

(KeyboardKeys key)

Source from the content-addressed store, hash-verified

746
747 /// <inheritdoc />
748 public override bool OnKeyDown(KeyboardKeys key)
749 {
750 // Navigate backward
751 if (key == KeyboardKeys.Backspace)
752 {
753 OnNavigateBack?.Invoke();
754 return true;
755 }
756
757 if (InputActions.Process(Editor.Instance, this, key))
758 return true;
759
760 // Check if sth is selected
761 if (HasSelection)
762 {
763 // Open
764 if (key == KeyboardKeys.Return && _selection.Count != 0)
765 {
766 foreach (var e in _selection.ToArray())
767 OnOpen?.Invoke(e);
768 return true;
769 }
770
771 // Movement with arrows
772 {
773 var root = _selection[0];
774 var size = root.Size;
775 var offset = Float2.Minimum;
776 ContentItem item = null;
777 if (key == KeyboardKeys.ArrowUp)
778 {
779 offset = new Float2(0, -size.Y);
780 }
781 else if (key == KeyboardKeys.ArrowDown)
782 {
783 offset = new Float2(0, size.Y);
784 }
785 else if (key == KeyboardKeys.ArrowRight)
786 {
787 offset = new Float2(size.X, 0);
788 }
789 else if (key == KeyboardKeys.ArrowLeft)
790 {
791 offset = new Float2(-size.X, 0);
792 }
793 if (offset != Float2.Minimum)
794 {
795 item = GetChildAt(root.Location + size / 2 + offset) as ContentItem;
796 }
797 if (item != null)
798 {
799 OnItemClick(item);
800 return true;
801 }
802 }
803 }
804
805 return base.OnKeyDown(key);

Callers

nothing calls this directly

Calls 2

ProcessMethod · 0.45
ToArrayMethod · 0.45

Tested by

no test coverage detected