# nodesnim/nodescontrol/button

Dark Mode

Search:
Group by:

Handles mouse clicks.

# Imports

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

# Types

    ButtonObj = object of LabelObj
      button_mask*: cint           ## Mask for handle clicks
      action_mask*: cint           ## BUTTON_RELEASE or BUTTON_CLICK.
      normal_background_color*: ColorRef ## color, when button is not pressed and not hovered.
      hover_background_color*: ColorRef ## color, when button hovered.
      press_background_color*: ColorRef ## color, when button pressed.
      normal_color*: ColorRef      ## text color, whenwhen button is not pressed and not hovered.
      hover_color*: ColorRef       ## text color, when button hovered.
      press_color*: ColorRef       ## text color, when button pressed.
      on_touch*: proc (self: ButtonRef; x, y: float): void ## This called, when user clicks on button.

    ButtonRef = ref ButtonObj

# Procs

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

  Creates a new Button node.

  Arguments:

  - `name` is a node name.

  Examples:

      var my_button = Button("Button")

# Methods

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

  this method uses in the `window.nim`.

    method duplicate(self: ButtonRef; obj: var ButtonObj): ButtonRef {...}{.base, raises: [],
        tags: [].}

  Duplicates Button object and creates a new Button node pointer.

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

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