# nodesnim/nodescontrol/texture_button

Dark Mode

Search:
Group by:

It is the convenient alternative of the Button node.

# Imports

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

# Types

    TextureButtonObj = object of LabelObj
      button_mask*: cint           ## Mask for handle clicks
      action_mask*: cint           ## BUTTON_RELEASE or BUTTON_CLICK.
      normal_background_texture*: GlTextureObj ## texture, when button is not pressed and not hovered.
      hover_background_texture*: GlTextureObj ## texture, when button hovered.
      press_background_texture*: GlTextureObj ## texture, 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: TextureButtonRef; x, y: float): void ## This called, when user clicks on button.

    TextureButtonRef = ref TextureButtonObj

# Procs

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

  Creates a new TextureButton node.

  Arguments:

  - `name` is a node name.

  Examples:

      var my_button = TextureButton("TextureButton")

# Methods

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

  this method uses in the `window.nim`.

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

  Duplicates TextureButton object and creates a new TextureButton node.

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

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

    method setNormalTexture(self: TextureButtonRef; texture: GlTextureObj) {...}{.base,
        raises: [], tags: [].}

  Changes button texture, when it not pressed and not hovered.

    method setHoverTexture(self: TextureButtonRef; texture: GlTextureObj) {...}{.base,
        raises: [], tags: [].}

  Changes button texture, when it hovered.

    method setPressTexture(self: TextureButtonRef; texture: GlTextureObj) {...}{.base,
        raises: [], tags: [].}

  Changes button texture, when it pressed.