切换标签页
This commit is contained in:
@@ -13,8 +13,6 @@ namespace NBF
|
||||
private readonly List<object> _listData = new List<object>();
|
||||
|
||||
public event Action<object> OnClickItem;
|
||||
|
||||
public int SelectedIndex => List.selectedIndex;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
@@ -23,21 +21,22 @@ namespace NBF
|
||||
List.onClickItem.Add(OnClickListItem);
|
||||
}
|
||||
|
||||
public void SetListData(List<object> listData)
|
||||
public void SetListData(List<object> listData,ListSelectionMode selectionMode = ListSelectionMode.Single)
|
||||
{
|
||||
_listData.Clear();
|
||||
foreach (var obj in listData)
|
||||
{
|
||||
_listData.Add(obj);
|
||||
}
|
||||
|
||||
List.selectionMode = selectionMode;
|
||||
List.numItems = _listData.Count;
|
||||
List.ScrollToView(0);
|
||||
}
|
||||
|
||||
void OnClickListItem(EventContext context)
|
||||
{
|
||||
Debug.Log($"con={context.data} nm={context.sender}");
|
||||
OnClickItem?.Invoke(null);
|
||||
OnClickItem?.Invoke(context.data);
|
||||
}
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace NBF
|
||||
}
|
||||
|
||||
Menu.OnTabChange += ChangeTab;
|
||||
|
||||
List.OnClickItem += OnClickItem;
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
@@ -51,6 +53,13 @@ namespace NBF
|
||||
List.SetListData(listData.ListData);
|
||||
}
|
||||
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if(item is not ShopGearItem shopGearItem) return;
|
||||
Log.Info($"click item ={shopGearItem.GearData.title}");
|
||||
}
|
||||
|
||||
private void OnClick(GComponent btn)
|
||||
{
|
||||
// if (btn == BtnClose)
|
||||
|
||||
Reference in New Issue
Block a user