test10.nim 462 B

12345678910111213141516171819202122232425
  1. # --- Test 10. Use Button node. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. main = Scene("Main")
  6. button = Button()
  7. main.addChild(button)
  8. button.setText("Press me!")
  9. button.resize(256, 64)
  10. button.setAnchor(0.5, 0.5, 0.5, 0.5)
  11. button.on_touch =
  12. proc(self: ButtonRef, x, y: float) = # This called when user clicks on the button
  13. button.setText("Clicked in " & $x & ", " & $y & " position.")
  14. addScene(main)
  15. setMainScene("Main")
  16. windowLaunch()