nodesnim/nodescontrol/switch

Displays colour rectangle.

Types

SwitchObj = object of ControlPtr
  value*: bool
  color_enable*, color_disable*: ColorRef
  back_enable*, back_disable*: ColorRef
  on_toggle*: proc (toggled: bool): void ## This called when switch toggled.
  
SwitchPtr = ptr SwitchObj

Procs

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

Creates a new Switch pointer.

Arguments:

  • name is a node name.

Examples:

var colorrect1 = Switch("Switch")

Methods

method draw(self: SwitchPtr; w, h: GLfloat) {...}{.raises: [GLerror, Exception],
                                        tags: [RootEffect].}
this method uses in the window.nim.
method duplicate(self: SwitchPtr): SwitchPtr {...}{.base, raises: [], tags: [].}
Duplicates Switch object and create a new Switch pointer.
method handle(self: SwitchPtr; event: InputEvent; mouse_on: var NodePtr) {...}{.
    raises: [Exception], tags: [RootEffect].}
Handles user input. This uses in the window.nim.
method toggle(self: SwitchPtr) {...}{.base, raises: [], tags: [].}
Toggles value.