mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
!W 搜索时按下↓键切换焦点到TreeView
This commit is contained in:
parent
eb3d24ff1d
commit
07217505e6
@ -10,6 +10,7 @@ namespace XNodeEditor {
|
|||||||
{
|
{
|
||||||
private SearchField _search;
|
private SearchField _search;
|
||||||
private MenuTreeView _menuTree;
|
private MenuTreeView _menuTree;
|
||||||
|
public Action OnCloseA;
|
||||||
public MenuPopupWindow()
|
public MenuPopupWindow()
|
||||||
{
|
{
|
||||||
_search = new SearchField();
|
_search = new SearchField();
|
||||||
@ -41,6 +42,11 @@ namespace XNodeEditor {
|
|||||||
_search.SetFocus();
|
_search.SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnClose()
|
||||||
|
{
|
||||||
|
OnCloseA?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
private string _str;
|
private string _str;
|
||||||
public override void OnGUI(Rect rect)
|
public override void OnGUI(Rect rect)
|
||||||
{
|
{
|
||||||
@ -49,6 +55,8 @@ namespace XNodeEditor {
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_action();
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
{
|
{
|
||||||
_str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str);
|
_str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str);
|
||||||
@ -60,6 +68,22 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
_menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20)));
|
_menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _action()
|
||||||
|
{
|
||||||
|
Event e = Event.current;
|
||||||
|
switch (e.type)
|
||||||
|
{
|
||||||
|
case EventType.KeyDown:
|
||||||
|
|
||||||
|
if (e.keyCode == KeyCode.DownArrow && !_menuTree.HasFocus())
|
||||||
|
{
|
||||||
|
_menuTree.SetFocusAndEnsureSelectedItem();
|
||||||
|
e.Use();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class MenuTreeView:TreeView
|
public class MenuTreeView:TreeView
|
||||||
{
|
{
|
||||||
@ -193,6 +217,38 @@ namespace XNodeEditor {
|
|||||||
{
|
{
|
||||||
return Root;
|
return Root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void KeyEvent()
|
||||||
|
{
|
||||||
|
Event e = Event.current;
|
||||||
|
switch (e.type)
|
||||||
|
{
|
||||||
|
case EventType.KeyDown:
|
||||||
|
|
||||||
|
if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter)
|
||||||
|
{
|
||||||
|
DoubleClickedItem(GetSelection()[0]);
|
||||||
|
e.Use();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _action()
|
||||||
|
{
|
||||||
|
Event e = Event.current;
|
||||||
|
switch (e.type)
|
||||||
|
{
|
||||||
|
case EventType.KeyDown:
|
||||||
|
|
||||||
|
if (e.keyCode == KeyCode.DownArrow && !HasFocus())
|
||||||
|
{
|
||||||
|
this.SetFocusAndEnsureSelectedItem();
|
||||||
|
e.Use();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. </summary>
|
/// <summary> Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user