public override bool OnClick(UIEvent clickEvent) { if (!clickEvent.heldDown && Element.MouseWasDown()) { Element.Focus(); // Move the cursor to the click point: int localClickX = clickEvent.clientX - Element.Style.Computed.OffsetLeft + Element.Style.Computed.ScrollLeft; int localClickY = clickEvent.clientY - Element.Style.Computed.OffsetTop + Element.Style.Computed.ScrollTop; 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(localClickX, localClickY); } } MoveCursor(index, true); } base.OnClick(clickEvent); clickEvent.stopPropagation(); return(true); }
/// <summary>This gets called when the element is clicked on. /// It's onmousedown points at this method.</summary> public static void StartScroll(UIEvent e){ if(!e.isLeftMouse){ // Not a left click. return; } // Store the current position of the mouse, and the current scroll offset. // We want to find how many pixels it's moved by since it went down: StartY=e.clientY + e.target.scrollTop; // Store the element being scrolled: Scrolling=e.target; // Focus the element - this will cause onmousemove to run: Scrolling.Focus(); }
/// <summary>If there is an element focused, this will move focus to the nearest focusable element to the right. /// You can define 'focusable' on any element, or use a tag that is focusable anyway (input, textarea, a etc). /// You can also define focus-right="anElementID" to override which element will be focused next.</summary> public static void MoveRight() { if (Current == null) { return; } // Grab the element to the right: Element element = Input.Focused.GetFocusableRight(); if (element != null) { // Focus it: element.Focus(); } }
/// <summary>If there is an element focused, this will move focus to the nearest focusable element below. /// You can define 'focusable' on any element, or use a tag that is focusable anyway (input, textarea, a etc). /// You can also define focus-down="anElementID" to override which element will be focused next.</summary> public static void MoveDown() { if (Current == null) { return; } // Grab the element below: Element element = Input.Focused.GetFocusableBelow(); if (element != null) { // Focus it: element.Focus(); } }
/// <summary>If there is an element focused, this will move focus to the nearest focusable element above. /// You can define 'focusable' on any element, or use a tag that is focusable anyway (input, textarea, a etc). /// You can also define focus-up="anElementID" to override which element will be focused next.</summary> public static void MoveUp() { if (Current == null) { return; } // Grab the element above: Element element = Input.Focused.GetFocusableAbove(); if (element != null) { // Focus it: element.Focus(); } }
/// <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); } } }
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); }