Ejemplo n.º 1
0
		/// <summary>Generates a new text element.</summary>
		/// <returns>A new html text element.</returns>
		protected override MLTextElement CreateTextElement(){
			TextElement result=new TextElement(Document,this);
			AppendNewChild(result);
			return result;
		}
Ejemplo n.º 2
0
        public override bool OnClick(UIEvent clickEvent)
        {
            // Did the mouse go up, and was the element clicked down on too?
            if (!clickEvent.heldDown && Element.MouseWasDown())
            {
                // Focus it:
                Element.Focus();

                if (Type == InputType.Submit)
                {
                    // Find the form and then attempt to submit it.
                    FormTag form = Element.form;
                    if (form != null)
                    {
                        form.submit();
                    }
                }
                else if (IsScrollInput())
                {
                    // Clicked somewhere on a scrollbar:
                    // Figure out where the click was, and scroll there.
                }
                else if (Type == InputType.Radio)
                {
                    Select();
                }
                else if (Type == InputType.Checkbox)
                {
                    if (Checked)
                    {
                        Unselect();
                    }
                    else
                    {
                        Select();
                    }
                }
                else if (IsTextInput())
                {
                    // Move the cursor to the click point:
                    int localClick = clickEvent.clientX - Element.Style.Computed.OffsetLeft + Element.Style.Computed.ScrollLeft;
                    int index      = 0;

                    if (Element.childNodes.Count > 1)
                    {
                        // Note: If it's equal to 1, ele[0] is the cursor.
                        TextElement text = (TextElement)(Element.childNodes[0]);
                        if (text != null)
                        {
                            index = text.LetterIndex(localClick);
                        }
                    }

                    MoveCursor(index, true);
                }
            }

            base.OnClick(clickEvent);
            clickEvent.stopPropagation();

            return(true);
        }