public void AddItem(string caption, string name = null, Function callback = null) { GComponent item = _list.AddItemFromPool().asCom; item.GetChildByName("title").asTextField.text = caption; item.name = name; item.data = callback; }
override public void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("ComboBox"); string str; _buttonController = GetController("button"); _titleObject = GetChildByName("title") as GTextField; str = (string)xml.GetAttribute("dropdown"); if (string.IsNullOrEmpty(str)) { Debug.Log(this.resourceURL + ": 需要定义下拉框资源"); return; } _dropdownObject = UIPackage.CreateObjectFromURL(str) as GComponent; if (_dropdownObject == null) { Debug.Log(this.resourceURL + ": 下拉框必须为元件"); return; } _list = _dropdownObject.GetChildByName("list") as GList; if (_list == null) { Debug.Log(this.resourceURL + ": 下拉框的弹出元件里必须包含名为list的列表"); return; } _list.AddEventListener(ItemEvent.CLICK, __clickItemObsolete); _list.onClickItem.Add(__clickItem); _list.AddRelation(_dropdownObject, RelationType.Width); _dropdownObject.AddRelation(_list, RelationType.Height); _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OVER, __rolloverObsolete); _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OUT, __rolloutObsolete); _displayObject.AddEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mousedown); displayObject.onRollOver.Add(__rollover); displayObject.onRollOut.Add(__rollout); displayObject.onTouchBegin.Add(__touchBegin); }
public PopupMenu(int width = 100, string resourceURL = null) { if (resourceURL == null) { resourceURL = UIConfig.popupMenu; } _contentPane = UIPackage.CreateObjectFromURL(resourceURL).asCom; _contentPane.AddEventListener(EventContext.ADDED_TO_STAGE, __addedToStage); _contentPane.width = width; _list = _contentPane.GetChildByName("list").asList; _list.RemoveChildrenToPool(); _list.AddRelation(_contentPane, RelationType.Width); _contentPane.AddRelation(_list, RelationType.Height); _list.AddEventListener(ItemEvent.CLICK, __clickItem); }
public void SetItemText(string name, string caption) { GComponent item = _list.GetChildByName(name).asCom; item.GetChildByName("title").asTextField.text = caption; }