test34.nim 408 B

123456789101112131415161718192021222324
  1. # --- Test 34. Use Switch node. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. mainobj: SceneObj
  6. main = Scene("Main", mainobj)
  7. switchobj: SwitchObj
  8. switch = Switch(switchobj)
  9. main.addChild(switch)
  10. switch.move(128, 64)
  11. switch.on_toggle =
  12. proc(self: SwitchPtr, toggled: bool) = # this called when the user toggles switch.
  13. echo toggled
  14. addScene(main)
  15. setMainScene("Main")
  16. windowLaunch()