test23.nim 827 B

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