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 (self: SwitchPtr; toggled: bool): void ## This called when switch toggled.
  
SwitchPtr = ptr SwitchObj

Procs

proc Switch(name: string; variable: var SwitchObj): SwitchPtr {...}{.raises: [], tags: [].}

Creates a new Switch pointer.

Arguments:

  • name is a node name.
  • variable is a SwitchObj variable

Examples:

var
  colorrect1_obj: SwitchObj
  colorrect1 = Switch("Switch", colorrect1_obj)
proc Switch(obj: var SwitchObj): SwitchPtr {...}{.inline, raises: [], tags: [].}

Creates a new Switch pointer with default node name "Switch".

Arguments:

  • variable is a SwitchObj variable

Examples:

var
  colorrect1_obj: SwitchObj
  colorrect1 = Switch(colorrect1_obj)

Methods

method draw(self: SwitchPtr; w, h: GLfloat) {...}{.raises: [GLerror, Exception],
                                        tags: [RootEffect].}
this method uses in the window.nim.
method duplicate(self: SwitchPtr; obj: var SwitchObj): 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.