class_popup.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Popup.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Popup:
  6. Popup
  7. =====
  8. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`PopupDialog<class_PopupDialog>`, :ref:`PopupMenu<class_PopupMenu>`, :ref:`PopupPanel<class_PopupPanel>`, :ref:`WindowDialog<class_WindowDialog>`
  10. Base container control for popups and dialogs.
  11. Description
  12. -----------
  13. Popup is a base :ref:`Control<class_Control>` used to show dialogs and popups. It's a subwindow and modal by default (see :ref:`Control<class_Control>`) and has helpers for custom popup behavior. All popup methods ensure correct placement within the viewport.
  14. Properties
  15. ----------
  16. +-------------------------+--------------------------------------------------------------+-------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`popup_exclusive<class_Popup_property_popup_exclusive>` | ``false`` |
  18. +-------------------------+--------------------------------------------------------------+-------------------------------+
  19. | :ref:`bool<class_bool>` | visible | ``false`` *(parent override)* |
  20. +-------------------------+--------------------------------------------------------------+-------------------------------+
  21. Methods
  22. -------
  23. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`popup<class_Popup_method_popup>` **(** :ref:`Rect2<class_Rect2>` bounds=Rect2( 0, 0, 0, 0 ) **)** |
  25. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`popup_centered<class_Popup_method_popup_centered>` **(** :ref:`Vector2<class_Vector2>` size=Vector2( 0, 0 ) **)** |
  27. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`popup_centered_clamped<class_Popup_method_popup_centered_clamped>` **(** :ref:`Vector2<class_Vector2>` size=Vector2( 0, 0 ), :ref:`float<class_float>` fallback_ratio=0.75 **)** |
  29. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`popup_centered_minsize<class_Popup_method_popup_centered_minsize>` **(** :ref:`Vector2<class_Vector2>` minsize=Vector2( 0, 0 ) **)** |
  31. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`popup_centered_ratio<class_Popup_method_popup_centered_ratio>` **(** :ref:`float<class_float>` ratio=0.75 **)** |
  33. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_as_minsize<class_Popup_method_set_as_minsize>` **(** **)** |
  35. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. Signals
  37. -------
  38. .. _class_Popup_signal_about_to_show:
  39. - **about_to_show** **(** **)**
  40. Emitted when a popup is about to be shown. This is often used in :ref:`PopupMenu<class_PopupMenu>` to clear the list of options then create a new one according to the current context.
  41. ----
  42. .. _class_Popup_signal_popup_hide:
  43. - **popup_hide** **(** **)**
  44. Emitted when a popup is hidden.
  45. Constants
  46. ---------
  47. .. _class_Popup_constant_NOTIFICATION_POST_POPUP:
  48. .. _class_Popup_constant_NOTIFICATION_POPUP_HIDE:
  49. - **NOTIFICATION_POST_POPUP** = **80** --- Notification sent right after the popup is shown.
  50. - **NOTIFICATION_POPUP_HIDE** = **81** --- Notification sent right after the popup is hidden.
  51. Property Descriptions
  52. ---------------------
  53. .. _class_Popup_property_popup_exclusive:
  54. - :ref:`bool<class_bool>` **popup_exclusive**
  55. +-----------+----------------------+
  56. | *Default* | ``false`` |
  57. +-----------+----------------------+
  58. | *Setter* | set_exclusive(value) |
  59. +-----------+----------------------+
  60. | *Getter* | is_exclusive() |
  61. +-----------+----------------------+
  62. If ``true``, the popup will not be hidden when a click event occurs outside of it, or when it receives the ``ui_cancel`` action event.
  63. **Note:** Enabling this property doesn't affect the Close or Cancel buttons' behavior in dialogs that inherit from this class. As a workaround, you can use :ref:`WindowDialog.get_close_button<class_WindowDialog_method_get_close_button>` or :ref:`ConfirmationDialog.get_cancel<class_ConfirmationDialog_method_get_cancel>` and hide the buttons in question by setting their :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property to ``false``.
  64. Method Descriptions
  65. -------------------
  66. .. _class_Popup_method_popup:
  67. - void **popup** **(** :ref:`Rect2<class_Rect2>` bounds=Rect2( 0, 0, 0, 0 ) **)**
  68. Popup (show the control in modal form).
  69. ----
  70. .. _class_Popup_method_popup_centered:
  71. - void **popup_centered** **(** :ref:`Vector2<class_Vector2>` size=Vector2( 0, 0 ) **)**
  72. Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by ``size``.
  73. ----
  74. .. _class_Popup_method_popup_centered_clamped:
  75. - void **popup_centered_clamped** **(** :ref:`Vector2<class_Vector2>` size=Vector2( 0, 0 ), :ref:`float<class_float>` fallback_ratio=0.75 **)**
  76. Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to ``size``, then ensuring the popup is no larger than the viewport size multiplied by ``fallback_ratio``.
  77. ----
  78. .. _class_Popup_method_popup_centered_minsize:
  79. - void **popup_centered_minsize** **(** :ref:`Vector2<class_Vector2>` minsize=Vector2( 0, 0 ) **)**
  80. Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than ``minsize``.
  81. ----
  82. .. _class_Popup_method_popup_centered_ratio:
  83. - void **popup_centered_ratio** **(** :ref:`float<class_float>` ratio=0.75 **)**
  84. Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen.
  85. ----
  86. .. _class_Popup_method_set_as_minsize:
  87. - void **set_as_minsize** **(** **)**
  88. Shrink popup to keep to the minimum size of content.
  89. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  90. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  91. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`