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.
  • Field Details

  • Constructor Details

    • TextView

      public TextView()
      Constructor.
  • Method Details

    • getTextArea

      public TextArea getTextArea()
      Returns the TextArea.
    • createTextArea

      protected TextArea createTextArea()
      Creates the TextArea.
    • getScrollView

      public ScrollView getScrollView()
      Returns the ScrollView.
    • getTextDoc

      public TextDoc getTextDoc()
      Returns the TextDoc.
    • getTextBox

      public TextBox getTextBox()
      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
    • isEditable

      public boolean isEditable()
      Returns whether Text shape is editable.
    • setEditable

      public void setEditable(boolean aValue)
      Sets whether Text shape is editable.
    • isWrapLines

      public boolean isWrapLines()
      Returns whether to wrap lines that overrun bounds.
    • setWrapLines

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

      public boolean isRichText()
      Returns whether text supports multiple styles.
    • getDefaultStyle

      public TextStyle getDefaultStyle()
      Returns the default style for text.
    • setDefaultStyle

      public void setDefaultStyle(TextStyle aStyle)
      Sets the default style.
    • getDefaultLineStyle

      public TextLineStyle getDefaultLineStyle()
      Returns the default line style for text.
    • setDefaultLineStyle

      public void setDefaultLineStyle(TextLineStyle aLineStyle)
      Sets the default line style.
    • isFireActionOnEnterKey

      public boolean isFireActionOnEnterKey()
      Returns whether text view fires action on return.
    • setFireActionOnEnterKey

      public void setFireActionOnEnterKey(boolean aValue)
      Sets whether text area sends action on return.
    • isFireActionOnFocusLost

      public boolean isFireActionOnFocusLost()
      Returns whether text view fires action on focus lost (if text changed).
    • 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.
    • getSelAnchor

      public int getSelAnchor()
      Returns the initial character index of the selection (usually SelStart).
    • 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.
    • getFont

      public Font getFont()
      Returns the font of the current selection or cursor.
      Overrides:
      getFont in class View
    • setFont

      public void setFont(Font aFont)
      Sets the font of the current selection or cursor.
      Overrides:
      setFont in class ParentView
    • getTextFill

      public Paint getTextFill()
      Returns the color of the current selection or cursor.
    • setTextFill

      public void setTextFill(Paint aColor)
      Sets the color of the current selection or cursor.
    • getUndoer

      public Undoer getUndoer()
      Returns the undoer.
    • undo

      public boolean undo()
      Called to undo the last edit operation in the editor.
    • redo

      public boolean redo()
      Called to redo the last undo operation in the 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
    • 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