Esempio n. 1
0
        /// <summary>Drops this select box down.</summary>
        public void Drop()
        {
            if (Dropped)
            {
                return;
            }
            Dropped = true;
            Element.Focus();
            Element ddBox = GetDropdownBox();

            if (ddBox == null)
            {
                return;
            }

            ddBox.style.display = "block";

            // Locate it to the select:
            ComputedStyle computed    = Element.Style.Computed;
            ComputedStyle boxComputed = ddBox.Style.Computed;

            boxComputed.PositionLeft = computed.OffsetLeft;
            boxComputed.InnerWidth   = computed.InnerWidth;
            boxComputed.FixedWidth   = true;
            boxComputed.SetPixelWidth(true);

            boxComputed.PositionTop = computed.OffsetTop + computed.PaddedHeight;


            ddBox.childNodes = null;
            ddBox.innerHTML  = "";

            if (Options != null)
            {
                foreach (Element child in Options)
                {
                    ddBox.AppendNewChild(child);
                }
            }
        }
Esempio n. 2
0
        /// <summary>Sets the value of this textarea, optionally as a html string.</summary>
        /// <param name="value">The value to set.</param>
        /// <param name="html">True if the value can safely contain html.</param>
        public void SetValue(string value, bool html)
        {
            if (MaxLength != int.MaxValue)
            {
                // Do we need to clip it?
                if (value.Length > MaxLength)
                {
                    // Yep!
                    value = value.Substring(0, MaxLength);
                }
            }

            if (CursorIndex > value.Length)
            {
                MoveCursor(0);
            }

            // Fire onchange:
            Element.Run("onchange");

            Element["value"] = Value = value;

            if (html)
            {
                Element.innerHTML = value;
            }
            else
            {
                Element.innerHTML = Wrench.Text.Escape(value).Replace("\n", "<br>");
            }

            if (Cursor != null)
            {
                Element.AppendNewChild(Cursor);
            }
        }
Esempio n. 3
0
        /// <summary>Sets the value of this input box, optionally as a html string.</summary>
        /// <param name="value">The value to set.</param>
        /// <param name="html">True if the value can safely contain html.</param>
        public void SetValue(string value, bool html)
        {
            if (IsScrollInput())
            {
                return;
            }

            if (MaxLength != int.MaxValue)
            {
                // Do we need to clip it?
                if (value != null && value.Length > MaxLength)
                {
                    // Yep!
                    value = value.Substring(0, MaxLength);
                }
            }

            if (value == null || CursorIndex > value.Length)
            {
                MoveCursor(0);
            }

            // Fire onchange:
            Element.Run("onchange");

            Element["value"] = Value = value;
            if (!IsBoolInput())
            {
                if (Hidden)
                {
                    // Unfortunately the new string(char,length); constructor isn't reliable.
                    // Build the string manually here.
                    StringBuilder sb = new StringBuilder("", value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        sb.Append('*');
                    }

                    if (html)
                    {
                        Element.innerHTML = sb.ToString();
                    }
                    else
                    {
                        Element.textContent = sb.ToString();
                    }
                }
                else
                {
                    if (html)
                    {
                        Element.innerHTML = value;
                    }
                    else
                    {
                        Element.textContent = value;
                    }
                }
            }

            if (IsTextInput())
            {
                if (Cursor != null)
                {
                    Element.AppendNewChild(Cursor);
                }
            }
        }