完成按键输入按键显示
This commit is contained in:
@@ -15,6 +15,14 @@ namespace NBF
|
||||
private void OnInited()
|
||||
{
|
||||
List.onClickItem.Add(OnClickItem);
|
||||
LeftList.onClickItem.Add(OnClickItem);
|
||||
InputManager.OnUIInvokeChange += OnUIInvokeChange;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
InputManager.OnUIInvokeChange -= OnUIInvokeChange;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void OnClickItem(EventContext context)
|
||||
@@ -25,29 +33,26 @@ namespace NBF
|
||||
Debug.Log("模拟点击===");
|
||||
}
|
||||
|
||||
public void Use(UIPanel panel)
|
||||
private void OnUIInvokeChange()
|
||||
{
|
||||
_panel = panel;
|
||||
List.RemoveChildrenToPool();
|
||||
LeftList.RemoveChildrenToPool();
|
||||
|
||||
// AddButtonItem(OnUse, "");
|
||||
// AddButtonItem(OnTab, InputDef.UI.Tab);
|
||||
// AddButtonItem(OnEnter, InputDef.UI.Enter);
|
||||
// AddButtonItem(OnBack, InputDef.UI.Back);
|
||||
var invokes = InputManager.Instance.GetUsableInvokes();
|
||||
foreach (var uiInputInvoke in invokes)
|
||||
{
|
||||
var invokeData = uiInputInvoke.InputInvoke;
|
||||
if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomLeft)
|
||||
{
|
||||
AddButton(invokeData.Name, invokeData.Key, false);
|
||||
}
|
||||
else if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomRight)
|
||||
{
|
||||
AddButton(invokeData.Name, invokeData.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void AddRightButton(string inputName, string showName = "")
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace NBF
|
||||
OnTabChange?.Invoke(List.selectedIndex);
|
||||
}
|
||||
|
||||
private void OnClickBtnPrev()
|
||||
public void OnClickBtnPrev()
|
||||
{
|
||||
if (List.selectedIndex > 0)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace NBF
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
private void OnClickBtnNext()
|
||||
public void OnClickBtnNext()
|
||||
{
|
||||
if (List.selectedIndex < List.numItems - 1)
|
||||
{
|
||||
|
||||
@@ -12,12 +12,9 @@ namespace NBF
|
||||
public partial class CommonSubMenu : GComponent
|
||||
{
|
||||
public event Action<int> OnTabChange;
|
||||
private UIPanel _panel;
|
||||
|
||||
public void SetPanel(UIPanel panel)
|
||||
{
|
||||
_panel = panel;
|
||||
}
|
||||
private string _leftActionName;
|
||||
private string _rightActionName;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
@@ -25,31 +22,22 @@ namespace NBF
|
||||
BtnPrev.onClick.Add(OnClickBtnPrev);
|
||||
BtnNext.onClick.Add(OnClickBtnNext);
|
||||
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
// CommonSubMenu
|
||||
}
|
||||
|
||||
public void SetBtnActionName(string leftActionName, string rightActionName)
|
||||
{
|
||||
_leftActionName = leftActionName;
|
||||
_rightActionName = rightActionName;
|
||||
BtnPrev.SetData(leftActionName, string.Empty);
|
||||
BtnNext.SetData(rightActionName, string.Empty);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (_panel == null) return;
|
||||
if (!_panel.IsShowing) return;
|
||||
if (!_panel.IsTop) return;
|
||||
|
||||
if (action == InputDef.UI.SubPrev)
|
||||
{
|
||||
OnClickBtnPrev();
|
||||
}
|
||||
else if (action == InputDef.UI.SubNext)
|
||||
{
|
||||
OnClickBtnNext();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTabs(List<TabItemData> subItems, int selectIndex = 0)
|
||||
{
|
||||
List.RemoveChildrenToPool();
|
||||
@@ -79,7 +67,7 @@ namespace NBF
|
||||
OnTabChange?.Invoke(List.selectedIndex);
|
||||
}
|
||||
|
||||
private void OnClickBtnPrev()
|
||||
public void OnClickBtnPrev()
|
||||
{
|
||||
if (List.selectedIndex > 0)
|
||||
{
|
||||
@@ -93,7 +81,7 @@ namespace NBF
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
private void OnClickBtnNext()
|
||||
public void OnClickBtnNext()
|
||||
{
|
||||
if (List.selectedIndex < List.numItems - 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user