FairyGUI.Utils.HtmlInput.Create C# (CSharp) Method

Create() public method

public Create ( RichTextField owner, HtmlElement element ) : void
owner RichTextField
element HtmlElement
return void
        public void Create(RichTextField owner, HtmlElement element)
        {
            _owner = owner;
            _element = element;

            string type = element.GetString("type");
            if (type != null)
                type = type.ToLower();

            _hidden = type == "hidden";
            if (!_hidden)
            {
                int width = element.GetInt("width", 0);
                int height = element.GetInt("height", 0);
                _borderSize = element.GetInt("border", defaultBorderSize);
                Color borderColor = element.GetColor("border-color", defaultBorderColor);

                if (width == 0)
                {
                    width = element.space;
                    if (width > _owner.width / 2 || width < 100)
                        width = (int)_owner.width / 2;
                }
                if (height == 0)
                    height = element.format.size + 10 + _borderSize * 2;

                textInput.textFormat = element.format;
                textInput.displayAsPassword = type == "password";
                textInput.SetSize(width - _borderSize * 2, height - _borderSize * 2);
                textInput.maxLength = element.GetInt("maxlength", int.MaxValue);

                _border.SetXY(-_borderSize, -_borderSize);
                _border.SetSize(width, height);
                _border.DrawRect(_borderSize, borderColor, new Color(0, 0, 0, 0));
            }
            textInput.text = element.GetString("value");
        }

Usage Example

Example #1
0
 static public int Create(IntPtr l)
 {
     try {
         FairyGUI.Utils.HtmlInput self = (FairyGUI.Utils.HtmlInput)checkSelf(l);
         FairyGUI.RichTextField   a1;
         checkType(l, 2, out a1);
         FairyGUI.Utils.HtmlElement a2;
         checkType(l, 3, out a2);
         self.Create(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }