Package snap.view

Class TextView

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable

public class TextView extends ParentView
This view subclass wraps a TextArea in a ScrollView.
  • Constructor Details

    • TextView

      public TextView()
      Constructor.
    • TextView

      public TextView(boolean isRichText)
      Constructor with option for RichText.
  • Method Details

    • getTextArea

      public TextArea getTextArea()
      Returns the TextArea.
    • getScrollView

      public ScrollView getScrollView()
      Returns the ScrollView.
    • getTextBlock

      public TextBlock getTextBlock()
      Returns the text that is being edited.
    • getText

      public String getText()
      Returns the plain string of the text being edited.
      Overrides:
      getText in class View
    • setText

      public void setText(String aString)
      Set text string of text editor.
      Overrides:
      setText in class View
    • setWrapLines

      public void setWrapLines(boolean aValue)
      Sets whether to wrap lines that overrun bounds.
    • setFireActionOnFocusLost

      public void setFireActionOnFocusLost(boolean aValue)
      Sets whether text area sends action on focus lost (if text changed).
    • length

      public int length()
      Returns the number of characters in the text string.
    • charAt

      public char charAt(int anIndex)
      Returns the individual character at given index.
    • isSelEmpty

      public boolean isSelEmpty()
      Returns whether the selection is empty.
    • getSelIndex

      public int getSelIndex()
      Returns the final character index of the selection (usually SelEnd).
    • getSelStart

      public int getSelStart()
      Returns the character index of the start of the text selection.
    • getSelEnd

      public int getSelEnd()
      Returns the character index of the end of the text selection.
    • getSel

      public TextSel getSel()
      Returns the text selection.
    • setSel

      public void setSel(int newStartEnd)
      Sets the character index of the text cursor.
    • setSel

      public void setSel(int aStart, int aEnd)
      Sets the character index of the start and end of the text selection.
    • selectAll

      public void selectAll()
      Selects all the characters in the text editor.
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the width needed to display all characters.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the height needed to display all characters.
      Overrides:
      getPrefHeightImpl in class View
    • layoutImpl

      protected void layoutImpl()
      Actual method to layout children.
      Overrides:
      layoutImpl in class ParentView
    • getValuePropName

      public String getValuePropName()
      Returns a mapped property name.
      Overrides:
      getValuePropName in class View
    • setBorderRadius

      public void setBorderRadius(double aValue)
      Override to sync ScrollView and TextArea.
      Overrides:
      setBorderRadius in class View
    • textAreaDidPropChange

      protected void textAreaDidPropChange(PropChange aPC)
      Called when TextArea gets prop changes.
    • toXMLView

      public XMLElement toXMLView(XMLArchiver anArchiver)
      XML archival.
      Overrides:
      toXMLView in class ParentView
    • fromXMLView

      public void fromXMLView(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Overrides:
      fromXMLView in class ParentView