Ejemplo n.º 1
0
        public void RegisterItemEvents(List.Item item, Row row)
        {
            if (item.Data.IsButton() && row != null)
            {
                Data.Item data = item.Data.Copy();
                //Adding Events
                Data.Item.ButtonType type = data.GetButtonType();
                int rowId = row.GetId();

                Button button = item.GetComponent <Button>();
                if (useCustomButtonEvents)
                {
                    if (data.GetButtonType() == Data.Item.ButtonType.Add)
                    {
                        button.onClick.AddListener(delegate() { OnClick(eventsOnAdd, rowId); });
                    }
                    else if (data.GetButtonType() == Data.Item.ButtonType.Edit)
                    {
                        button.onClick.AddListener(delegate() { OnClick(eventsOnEdit, rowId); });
                    }
                    else if (data.GetButtonType() == Data.Item.ButtonType.Remove)
                    {
                        button.onClick.AddListener(delegate() { OnClick(eventsOnDelete, rowId); });
                    }
                    else if (data.GetButtonType() == Data.Item.ButtonType.Event)
                    {
                        button.onClick.AddListener(delegate() { OnClick(eventsOnClick, rowId); });
                    }
                }

                button.onClick.AddListener(delegate() { OnClick(data, rowId); });
            }
        }
Ejemplo n.º 2
0
        public void AddSublist()
        {
            GameObject obj  = new GameObject("Sublist");
            SubList    list = obj.AddComponent <SubList>();

            list.Initialize();
            list.transform.SetParent(itemsReference);
            //TODO možda:
            //Sublist.Initialize();  ->  IMultiList.Initialize(); -> AddComponentWithParameters

            Data.Item data  = new Data.Item("HEADER");
            List.Item item1 = CreateItem(data, obj.transform);
            item1.transform.SetParent(obj.transform);
            list.Add(item1);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adding items to parent and registering events for buttons in row
 /// </summary>
 /// <param name="dataItems"></param>
 /// <param name="parent">Parent can either be Sublist (header) or Row</param>
 public void AddItemsToParent(List <Data.Item> dataItems, ListComponent parent)
 {
     if (_idManager)
     {
         _idManager.RegisterListObject(parent);
     }
     foreach (Data.Item data in dataItems)
     {
         List.Item item = CreateItem(data, parent.GetTransform());
         if (parent.GetType() == typeof(Row))
         {
             RegisterItemEvents(item, (Row)parent);
         }
         parent.Add(item);
     }
     if (!useItemTypePrefabs)
     {
         parent.Initialize(personalize);
     }
     else
     {
         parent.Initialize();
     }
 }