# nodesnim/nodescontrol/rich_edit_text

Dark Mode

Search:
Group by:

It provides convenient text input. With it, you can set color and underlie for specific chars.

# Imports

../thirdparty/opengl, ../thirdparty/opengl/glut, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../core/color, ../core/color_text, ../nodes/node, control

# Types

    RichEditTextObj = object of ControlRef
      blit_caret*: bool
      blit_speed*: float
      blit_time*: float
      caret_position*: int
      font*: pointer               ## Glut font data.
      spacing*: float              ## Font spacing.
      size*: float                 ## Font size.
      text*: ColorTextRef
      hint_text*: ColorTextRef
      caret_color*: ColorRef
      text_align*: AnchorRef       ## Text align.
      on_edit*: proc (pressed_key: string): void ## This called when user press any key.

    RichEditTextRef = ref RichEditTextObj

# Procs

    proc RichEditText(name: string = "RichEditText"): RichEditTextRef {...}{.raises: [], tags: [].}

  Creates a new RichEditText.

  Arguments:

  - `name` is a node name.

  Examples:

      var text = RichEditText("RichEditText")

# Methods

    method getTextSize(self: RichEditTextRef): Vector2Ref {...}{.base, raises: [], tags: [].}

  Returns text size.

    method getLine(self: RichEditTextRef): int {...}{.base, raises: [], tags: [].}

  Returns current caret line.

    method getCharPositionUnderMouse(self: RichEditTextRef): int {...}{.base, raises: [],
        tags: [].}

  Returns char position under mouse.

    method getCharUnderMouse(self: RichEditTextRef): ColorCharRef {...}{.base, raises: [],
        tags: [].}

  Returns char under mouse

    method getWordPositionUnderMouse(self: RichEditTextRef): tuple[
        startpos, endpos: int] {...}{.base, raises: [], tags: [].}

  Returns words under mouse. Returns (-1, -1), if under mouse no founds words.

    method getWordUnderMouse(self: RichEditTextRef): ColorTextRef {...}{.base, raises: [],
        tags: [].}

  Returns words under mouse.

    method draw(self: RichEditTextRef; w, h: GLfloat) {...}{.raises: [GLerror, Exception],
        tags: [RootEffect].}

  This uses in the `window.nim`.

    method duplicate(self: RichEditTextRef): RichEditTextRef {...}{.base, raises: [], tags: [].}

  Duplicates RichEditText and create a new RichEditText.

    method handle(self: RichEditTextRef; event: InputEvent; mouse_on: var NodeRef) {...}{.
        raises: [Exception], tags: [RootEffect].}

  Handles user input. This uses in the `window.nim`.

    method setTextAlign(self: RichEditTextRef; align: AnchorRef) {...}{.base, raises: [],
        tags: [].}

  Changes text align.

    method setTextAlign(self: RichEditTextRef; x1, y1, x2, y2: float) {...}{.base, raises: [],
        tags: [].}

  Changes text align.

    method setText(self: RichEditTextRef; value: ColorTextRef) {...}{.base, raises: [], tags: [].}

  Changes RichEditText text.