test21.nim 682 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # --- Test 21. Use Popup node. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. main = Scene("Main")
  6. popup = Popup() # Create Popup node pointer.
  7. box = VBox()
  8. label = Label()
  9. smthnode = Node()
  10. label.setText("Hello")
  11. label.setTextAlign(0.5, 0.5, 0.5, 0.5)
  12. box.setChildAnchor(0.5, 0.1, 0.5, 0.1)
  13. box.setSizeAnchor(1, 1)
  14. popup.addChild(box)
  15. box.addChild(label)
  16. main.addChild(popup)
  17. main.addChild(smthnode)
  18. Input.addKeyAction("space", K_SPACE)
  19. smthnode.on_process =
  20. proc(self: NodeRef) =
  21. if Input.isActionJustPressed("space"):
  22. if popup.visible:
  23. popup.hide()
  24. else:
  25. popup.show()
  26. addScene(main)
  27. setMainScene("Main")
  28. windowLaunch()