快捷键操作

This commit is contained in:
bob
2025-06-04 12:55:36 +08:00
parent 30836558ae
commit 55f49e1af7
8 changed files with 90 additions and 32 deletions

View File

@@ -20,7 +20,8 @@ namespace NBF
{
var item = context.data as BtnTitleInputControl;
if (item == null) return;
item.OnAction?.Invoke();
InputManager.Instance.SendUIInput(item.ActionName);
Debug.Log("模拟点击===");
}
public void Use(IUIPanel panel)
@@ -29,38 +30,37 @@ namespace NBF
List.RemoveChildrenToPool();
LeftList.RemoveChildrenToPool();
InputManager.OnUICanceled += OnAction;
// AddButtonItem(OnUse, "");
// AddButtonItem(OnTab, InputDef.UI.Tab);
// AddButtonItem(OnEnter, InputDef.UI.Enter);
// AddButtonItem(OnBack, InputDef.UI.Back);
}
private void AddButtonItem(Action action, string actionName)
public void AddRightButton(string inputName, string showName = "")
{
if (action != null)
AddButton(inputName, string.Empty, true);
}
public void AddLeftButton(string inputName, string showName = "")
{
AddButton(inputName, string.Empty, false);
}
public void AddButton(string inputName, string showName = "", bool isRight = true)
{
if (isRight)
{
if (List.AddItemFromPool() is BtnTitleInputControl item)
{
item.OnAction = action;
item.ActionName = actionName;
item.SetData(inputName, showName);
}
}
}
private void OnAction(string action)
{
if (_panel == null || !_panel.IsShowing || !_panel.IsTop) return;
var children = List.GetChildren();
foreach (var child in children)
else
{
if (child is BtnTitleInputControl item)
if (LeftList.AddItemFromPool() is BtnTitleInputControl item)
{
if (action == item.ActionName)
{
item.OnAction?.Invoke();
}
item.SetData(inputName, showName);
}
}
}