/// <summary> /// Emulate entering text by user into input textbox. /// </summary> public static void EnterText(this HtmlTextAreaElement input, string text) { input.Value = text; var evt = input.OwnerDocument.CreateEvent("Event"); evt.InitEvent("change", false, false); input.DispatchEvent(evt); }
public void NotifyValueTextArea() { var x = new HtmlTextAreaElement(); x.NotifyValue(new ElementEventValue { Value = "lala" }); Assert.Equal("lala", x.Value); }
public void TextAreaProperties() { var x = new HtmlTextAreaElement { Cols = 1, MaxLength = 2, Rows = 3 }; Assert.Equal(1, x.Cols); Assert.Equal(2, x.MaxLength); Assert.Equal(3, x.Rows); }
CssBox CreateTextAreaElement(HtmlElement domE, CssBox parentBox, BoxSpec spec, HtmlHost host) { //mulitline //TODO: review default size of a textarea... HtmlTextAreaElement htmlTextAreaElem = (HtmlTextAreaElement)domE; var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 60, true); var subdomExtender = new TextAreaInputSubDomExtender(textbox); CssBox wrapperBox = CreateCssWrapper( host, textbox, textbox.GetPrimaryRenderElement(), spec, subdomExtender, true); textbox.KeyDown += (s, e) => { ((LayoutFarm.UI.IUIEventListener)domE).ListenKeyDown(e); }; htmlTextAreaElem.SubDomExtender = subdomExtender;//connect //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); //content of text area HtmlTextNode textNode = null; foreach (DomNode child in domE.GetChildNodeIterForward()) { switch (child.NodeKind) { case HtmlNodeKind.TextNode: { textNode = (HtmlTextNode)child; } break; } if (textNode != null) { break; } } if (textNode != null) { //if first line is blank line we skip //TODO: review here System.Collections.Generic.List <string> strList = new System.Collections.Generic.List <string>(); int lineCount = 0; using (System.IO.StringReader strReader = new System.IO.StringReader(new string(textNode.GetOriginalBuffer()))) { string line = strReader.ReadLine(); while (line != null) { if (lineCount == 0) { if (line.Trim() != string.Empty) { strList.Add(line); } } else { strList.Add(line); } lineCount++; line = strReader.ReadLine(); } if (strList.Count > 0) { //check last line line = strList[strList.Count - 1]; if (line.Trim() == string.Empty) { strList.RemoveAt(strList.Count - 1); } } } // if (strList.Count > 0) { textbox.SetText(strList); } } return(wrapperBox); }
public void SetUp() { _document = new HtmlDocument(); _textArea = (HtmlTextAreaElement)_document.CreateElement("textarea"); }
public static void ChangeText() { HtmlElement.GetById("txtSample").innerHTML = HtmlTextAreaElement.GetById("userinput").value; }
public static void ChangeFont() { HtmlElement.GetById("txtSample").style.fontFamily = HtmlSelectElement.GetById("ddFonts").value; HtmlTextAreaElement.GetById("userinput").value = HtmlSelectElement.GetById("ddFonts").options[HtmlSelectElement.GetById("ddFonts").selectedIndex].text; ChangeText(); }