guicomponents

## Class GTextField

- java.lang.Object
- - guicomponents.GComponent
  - - guicomponents.GTextField

- All Implemented Interfaces:
    GConstants, Comparable<Object>, PConstants

      public class GTextField
      extends GComponent

  The text field component.
  This component can be created to manage either a single line of text or multiple lines of text.
  If height of the component is too small to show a line of text because of the font size then it is increased.
  Enables user text input at runtime. Text can be selected using the mouse or keyboard shortcuts and then copied or cut to the clipboard. Text can also be pasted in. It supports text that is longer than the displayable area
  Author:
    Brendan Nichols & Peter Lager

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class guicomponents.GComponent

      `GComponent.Z_Order`

  - ### Field Summary

    - ### Fields inherited from class guicomponents.GComponent

      `eventType, fGlobalFont, globalColor, globalColorScheme, globalFont, localColor, localFont, tag, tagNo, z`

    - ### Fields inherited from interface processing.core.PConstants

      `ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_2D, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_STROKE_PERSPECTIVE, DISABLE_TEXTURE_CACHE, DISABLE_TEXTURE_MIPMAPS, DISABLE_TRANSFORM_CACHE, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ACCURATE_2D, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_STROKE_PERSPECTIVE, ENABLE_TEXTURE_CACHE, ENABLE_TEXTURE_MIPMAPS, ENABLE_TRANSFORM_CACHE, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z`

    - ### Fields inherited from interface guicomponents.GConstants

      `ADD_DUPLICATE, BACKGROUND, CHANGED, CLICKED, CLOSE_WINDOW, COLLAPSED, CTRL_ANGULAR, CTRL_HORIZONTAL, CTRL_VERTICAL, DESELECTED, DISABLE_AUTO_DRAW, DRAGGED, ENTERED, EXCP_IN_HANDLER, EXIT_APP, EXPANDED, FAMILY, FOREGROUND, HUD_UNSUPPORTED, INVALID_STATUS, JUSTIFICATION, JUSTIFICATION_FULL, JUSTIFICATION_NONE, KEEP_OPEN, MISSING, NONEXISTANT, NOT_PEASYCAM, POSTURE, POSTURE_OBLIQUE, POSTURE_REGULAR, PRESSED, RELEASED, RUNTIME_ERROR, SCROLL_DOWN, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLLBAR_HORIZONTAL, SCROLLBAR_VERTICAL, SCROLLBARS_AUTOHIDE, SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY, SELECTED, SET, SIZE, STRIKETHROUGH, STRIKETHROUGH_OFF, STRIKETHROUGH_ON, SUPERSCRIPT, SUPERSCRIPT_SUB, SUPERSCRIPT_SUPER, USER_COL_SCHEME, WEIGHT, WEIGHT_BOLD, WEIGHT_DEMIBOLD, WEIGHT_DEMILIGHT, WEIGHT_EXTRA_LIGHT, WEIGHT_EXTRABOLD, WEIGHT_HEAVY, WEIGHT_LIGHT, WEIGHT_MEDIUM, WEIGHT_REGULAR, WEIGHT_SEMIBOLD, WEIGHT_ULTRABOLD, WIDTH, WIDTH_CONDENSED, WIDTH_EXTENDED, WIDTH_REGULAR, WIDTH_SEMI_CONDENSED, WIDTH_SEMI_EXTENDED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GTextField(PApplet theApplet, String text, int x, int y, int width, int height)` Creates a single line GTextField object
    `GTextField(PApplet theApplet, String text, int x, int y, int width, int height, boolean multiLine)` Creates a single or multiple text line GTextField object

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `draw()` Draws the text field, contents, selection, and cursor to the screen.
    `void` | `drawORG()`
    `String` | `getSelectedText()` Get the highlighted (selected text)
    `boolean` | `getShowLines()` Are we showing separator lines
    `void` | `keyEvent(KeyEvent e)` receives KeyEvents forwarded to it by the GUIController if the current instance is currently in focus.
    `void` | `mouseEvent(MouseEvent e)` Mouse event handler - the focus cannot be lost by anything we do here - it has to be taken away when the mouse is pressed somewhere else.
    `boolean` | `scroll(int dir)` SCroll the text within the field
    `void` | `setFont(String fontname, int fontsize)` Set the font type and size for the textfield.
    `void` | `setFont(String fontname, int fontSize, int fontLeading)` Set the font, size and leading for the textfield.
    `void` | `setShowLines(boolean drawlines)` Whether or not to display separator lines
    `void` | `setText(String newValue)` Sets the contents of the text box and displays the specified string in the text box widget.
    `void` | `setTextAlign(int align)` This class does not support text alignment and uses the default left alignment.
    `String` | `viewText()` Returns the string of text that the text box can display

    - ### Methods inherited from class guicomponents.GComponent

      `add, addAbsoluteControl, addCompoundControl, addEventHandler, addEventHandler, addRelativeControl, addXXX, calcAbsPosition, changeWindow, compareTo, contains, ctrlMode, dispose, getAlpha, getBorder, getCtrlMode, getEventType, getFocusObject, getHeight, getOpaque, getPApplet, getParent, getStyledText, getText, getTransform, getWidth, getX, getY, hasFocus, hasKeyFocus, isEnabled, isOver, isVisible, keyPressed, pre, remove, setAlpha, setBorder, setColorScheme, setEnabled, setFocus, setFontNew, setFontNew, setHeight, setLocalColorScheme, setOpaque, setRotation, setText, setTextNew, setTextNew, setVisible, setWidth, setX, setXY, setY, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### GTextField

          public GTextField(PApplet theApplet,
                    String text,
                    int x,
                    int y,
                    int width,
                    int height)

      Creates a single line GTextField object
      Parameters:
        `theApplet` -
        `text` - initial text to display
        `x` - horizontal position relative to PApplet or PPanel
        `y` - vertical position relative to PApplet or PPanel
        `width` - width of text field
        `height` - height of text field

    - #### GTextField

          public GTextField(PApplet theApplet,
                    String text,
                    int x,
                    int y,
                    int width,
                    int height,
                    boolean multiLine)

      Creates a single or multiple text line GTextField object
      Parameters:
        `theApplet` -
        `text` - initial text to display
        `x` - horizontal position relative to PApplet or PPanel
        `y` - vertical position relative to PApplet or PPanel
        `width` - width of text field
        `height` - height of text field
        `multiLine` - set to true for multi-line component

  - ### Method Detail

    - #### setFont

          public void setFont(String fontname,
                     int fontSize,
                     int fontLeading)

      Set the font, size and leading for the textfield.
      The height of the textfield will be increased if it is not possible to show a line of text due to the font size.
      Parameters:
        `fontname` -
        `fontSize` -
        `fontLeading` - line spacing

    - #### setFont

          public void setFont(String fontname,
                     int fontsize)

      Set the font type and size for the textfield.
      The height of the textfield will be increased if it is not possible to show a line of text due to the font size. Use the existing line spacing value (textLeading).
      Overrides:
        `setFont` in class `GComponent`
      Parameters:
        `fontname` -
        `fontsize` -

    - #### viewText

          public String viewText()

      Returns the string of text that the text box can display

    - #### getSelectedText

          public String getSelectedText()

      Get the highlighted (selected text)
      Returns:
        return the selected text

    - #### setText

          public void setText(String newValue)

      Sets the contents of the text box and displays the specified string in the text box widget.
      Fires SET event.
      Overrides:
        `setText` in class `GComponent`
      Parameters:
        `newValue` - the string to become the text field's contents

    - #### setTextAlign

          public void setTextAlign(int align)

      This class does not support text alignment and uses the default left alignment.
      This method simply displays a warning if G4P messages are enabled.
      Overrides:
        `setTextAlign` in class `GComponent`
      Parameters:
        `align` - the alignment flag

    - #### setShowLines

          public void setShowLines(boolean drawlines)

      Whether or not to display separator lines

    - #### getShowLines

          public boolean getShowLines()

      Are we showing separator lines
      Returns:
        true if using separator lines else false.

    - #### scroll

          public boolean scroll(int dir)

      SCroll the text within the field
      Parameters:
        `dir` -
      Returns:
        true if successful else false

    - #### mouseEvent

          public void mouseEvent(MouseEvent e)

      Mouse event handler - the focus cannot be lost by anything we do here - it has to be taken away when the mouse is pressed somewhere else.
      Overrides:
        `mouseEvent` in class `GComponent`
      Parameters:
        `e` - the MouseEvent to handle

    - #### keyEvent

          public void keyEvent(KeyEvent e)

      receives KeyEvents forwarded to it by the GUIController if the current instance is currently in focus.
      Parameters:
        `e` - the KeyEvent to be handled

    - #### draw

          public void draw()

      Draws the text field, contents, selection, and cursor to the screen.
      Overrides:
        `draw` in class `GComponent`

    - #### drawORG

          public void drawORG()

Processing library guicomponents by Peter Lager. (C) 2012