/// <summary>Unfocuses this element.</summary> public void blur() { FocusEvent fe = new FocusEvent("blur"); fe.SetTrusted(false); Unfocus(fe); }
/// <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); } }