test9.nim 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # --- Test 9. Extended Control events. --- #
  2. import nodesnim
  3. var
  4. window = newWindow("hello world", 640, 360)
  5. mainobj: SceneObj
  6. main_scene = Scene("Main", mainobj)
  7. colorobj: ColorRectObj
  8. color = ColorRect(colorobj)
  9. color1obj: ColorRectObj
  10. color1 = ColorRect(color1obj)
  11. main_scene.addChild(color)
  12. main_scene.addChild(color1)
  13. color1.click =
  14. proc(x, y: float) = # This called when the mouse clicks on the node.
  15. color1.move(3, 3)
  16. color.click =
  17. proc(x, y: float) = # This called when the mouse clicks on the node.
  18. echo "clicked in position: ", Vector2(x, y), "!"
  19. color.color.g = 0.6
  20. color.press =
  21. proc(x, y: float) = # This called when the mouse holds on.
  22. color.color.g += 0.01
  23. color.focused =
  24. proc() = # This called when the node gets focus.
  25. echo "hi"
  26. color.unfocused =
  27. proc() = # This called when the node loses focus.
  28. echo "bye("
  29. color.release =
  30. proc() = # This called when the mouse more not is pressed.
  31. echo ">.<"
  32. window.setMainScene(main_scene)
  33. window.launch()