nodesnim/nodescontrol/button

    Dark Mode
Search:
Group by:

Handles mouse clicks.

Types

ButtonTouchHandler = proc (self: ButtonRef; x, y: float)
ButtonObj = object of LabelObj
  button_mask*: cint         ## Mask for handle clicks
  action_mask*: cint         ## BUTTON_RELEASE or BUTTON_CLICK.
  normal_background*: DrawableRef ## color, when button is not pressed and not hovered.
  hover_background*: DrawableRef ## color, when button hovered.
  press_background*: DrawableRef ## color, when button pressed.
  on_touch*: ButtonTouchHandler ## 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.

Example:

var my_button = Button("Button")

Methods

method draw(self: ButtonRef; w, h: GLfloat) {...}{.
    raises: [GLerror, Exception, ResourceError], 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.