# nodesnim/nodescontrol/counter

Dark Mode

Search:
Group by:

Number counter box.

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../core/color, ../nodes/node, ../nodes/canvas, control, label

# Types

    CounterObj = object of ControlRef
      as_int*: bool                ## if true, then use integer representation.
      min_value*, value*, max_value*: float
      label*: LabelRef

    CounterRef = ref CounterObj

# Procs

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

  Creates a new Counter.

  Arguments:

  - `name` is a node name.

  Examples:

      var c = Counter("Counter")

# Methods

    method changeValue(self: CounterRef; value: float) {...}{.base, raises: [], tags: [].}

  Changes value, if it more than `min_value` and less than `max_value`.

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

  This uses in the `window.nim`.

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

  Duplicates Counter object and create a new Counter.

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

    method setMaxValue(self: CounterRef; value: float) {...}{.base, raises: [], tags: [].}

  Changes max value, if it more then current `value`.

    method setMinValue(self: CounterRef; value: float) {...}{.base, raises: [], tags: [].}

  Changes max value, if it less then current `value`.