test10.nim 442 B

1234567891011121314151617181920212223242526
  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.text = "Press me!"
  9. button.resize(256, 64)
  10. button.setAnchor(0.5, 0.5, 0.5, 0.5)
  11. button.on_click =
  12. proc(x, y: float) = # This called when user clicks on the button
  13. button.text = "Clicked in " & $x & ", " & $y & " position."
  14. addScene(main)
  15. setMainScene("Main")
  16. windowLaunch()