/// <summary>Called when the element is focused.</summary> internal override void OnFocusEvent(FocusEvent fe) { if (!IsTextInput() || Caret != null) { return; } if (innerHTML == Placeholder_ && Placeholder_ != "") { innerHTML = ""; } // Add a caret. Caret = Style.Computed.GetOrCreateVirtual(HtmlCaretElement.Priority, "caret") as HtmlCaretElement; }
/// <summary>Called when the element is unfocused/blurred.</summary> internal override void OnBlurEvent(FocusEvent fe) { if (Caret == null) { return; } // Remove the caret: Style.Computed.RemoveVirtual(HtmlCaretElement.Priority); Caret = null; if (innerHTML == "" && Placeholder_ != "") { innerHTML = Placeholder_; } }
internal override void OnBlurEvent(FocusEvent fe) { // Is the new focused element a child of dropdown? Dom.Element current = fe.focusing as Dom.Element; while (current != null) { if (current.Tag == "dropdown") { return; } current = current.parentElement; } Hide(); }
/// <summary>Focuses this element so it receives events such as keypresses.</summary> public void focus() { HtmlDocument doc = htmlDocument; if (doc.activeElement == this) { return; } // Focus out first: FocusEvent fe = new FocusEvent("focusout"); // It's trusted but doesn't bubble: fe.SetTrusted(false); fe.focusing = this; fe.relatedTarget = this; if (doc.activeElement != null) { if (!doc.activeElement.dispatchEvent(fe)) { return; } } // Focus in next: fe.Reset(); fe.EventType = "focusin"; fe.relatedTarget = doc.activeElement; if (!dispatchEvent(fe)) { return; } // Blur next: fe.Reset(); fe.relatedTarget = null; fe.EventType = "blur"; PowerUI.Input.LastFocusedDocument = doc; if (doc.activeElement != null) { (doc.activeElement as HtmlElement).Unfocus(fe); } doc.activeElement = this; // Update local style: Style.Computed.RefreshLocal(); #if MOBILE // Should we pop up the mobile keyboard? KeyboardMode mobile = OnShowMobileKeyboard(); if (Input.HandleKeyboard(mobile)) { Input.KeyboardText = value; } #endif // Reset so we can recycle it: fe.Reset(); fe.EventType = "focus"; // Dispatch and check if it got cancelled: if (dispatchEvent(fe)) { // Run the default for this element: OnFocusEvent(fe); } }
/// <summary>Called when this element becomes unfocused.</summary> internal virtual void OnBlurEvent(FocusEvent fe) { }