test10.nim 509 B

12345678910111213141516171819202122232425262728
  1. # --- Test 10. Use Button node. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. mainobj: SceneObj
  6. main = Scene("Main", mainobj)
  7. buttonobj: ButtonObj
  8. button = Button(buttonobj)
  9. main.addChild(button)
  10. button.text = "Press me!"
  11. button.resize(256, 64)
  12. button.anchor = Anchor(0.5, 0.5, 0.5, 0.5)
  13. button.on_click =
  14. proc(x, y: float) = # This called when user clicks on the button
  15. button.text = "Clicked in " & $x & ", " & $y & " position."
  16. addScene(main)
  17. setMainScene("Main")
  18. windowLaunch()