class_undoredo.rst 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the UndoRedo.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_UndoRedo:
  5. UndoRedo
  6. ========
  7. **Inherits:** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Helper to manage UndoRedo in the editor or custom tools.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Variant<class_variant>` | :ref:`add_do_method<class_UndoRedo_add_do_method>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method **)** vararg |
  16. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_do_property<class_UndoRedo_add_do_property>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)** |
  18. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`add_do_reference<class_UndoRedo_add_do_reference>` **(** :ref:`Object<class_object>` object **)** |
  20. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Variant<class_variant>` | :ref:`add_undo_method<class_UndoRedo_add_undo_method>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method **)** vararg |
  22. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`add_undo_property<class_UndoRedo_add_undo_property>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)** |
  24. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_undo_reference<class_UndoRedo_add_undo_reference>` **(** :ref:`Object<class_object>` object **)** |
  26. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`clear_history<class_UndoRedo_clear_history>` **(** **)** |
  28. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`commit_action<class_UndoRedo_commit_action>` **(** **)** |
  30. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`create_action<class_UndoRedo_create_action>` **(** :ref:`String<class_string>` name, :ref:`int<class_int>` merge_mode=0 **)** |
  32. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_string>` | :ref:`get_current_action_name<class_UndoRedo_get_current_action_name>` **(** **)** const |
  34. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`get_version<class_UndoRedo_get_version>` **(** **)** const |
  36. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`redo<class_UndoRedo_redo>` **(** **)** |
  38. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`undo<class_UndoRedo_undo>` **(** **)** |
  40. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. Enums
  42. -----
  43. .. _enum_UndoRedo_MergeMode:
  44. enum **MergeMode**
  45. - **MERGE_DISABLE** = **0**
  46. - **MERGE_ENDS** = **1**
  47. - **MERGE_ALL** = **2**
  48. Description
  49. -----------
  50. Helper to manage UndoRedo in the editor or custom tools. It works by storing calls to functions in both 'do' an 'undo' lists.
  51. Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action.
  52. Member Function Description
  53. ---------------------------
  54. .. _class_UndoRedo_add_do_method:
  55. - :ref:`Variant<class_variant>` **add_do_method** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method **)** vararg
  56. .. _class_UndoRedo_add_do_property:
  57. - void **add_do_property** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)**
  58. Set a property with a custom value.
  59. .. _class_UndoRedo_add_do_reference:
  60. - void **add_do_reference** **(** :ref:`Object<class_object>` object **)**
  61. Add a 'do' reference that will be erased if the 'do' history is lost. This is useful mostly for new nodes created for the 'do' call. Do not use for resources.
  62. .. _class_UndoRedo_add_undo_method:
  63. - :ref:`Variant<class_variant>` **add_undo_method** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method **)** vararg
  64. .. _class_UndoRedo_add_undo_property:
  65. - void **add_undo_property** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)**
  66. Undo setting of a property with a custom value.
  67. .. _class_UndoRedo_add_undo_reference:
  68. - void **add_undo_reference** **(** :ref:`Object<class_object>` object **)**
  69. Add an 'undo' reference that will be erased if the 'undo' history is lost. This is useful mostly for nodes removed with the 'do' call (not the 'undo' call!).
  70. .. _class_UndoRedo_clear_history:
  71. - void **clear_history** **(** **)**
  72. Clear the undo/redo history and associated references.
  73. .. _class_UndoRedo_commit_action:
  74. - void **commit_action** **(** **)**
  75. Commit the action. All 'do' methods/properties are called/set when this function is called.
  76. .. _class_UndoRedo_create_action:
  77. - void **create_action** **(** :ref:`String<class_string>` name, :ref:`int<class_int>` merge_mode=0 **)**
  78. Create a new action. After this is called, do all your calls to :ref:`add_do_method<class_UndoRedo_add_do_method>`, :ref:`add_undo_method<class_UndoRedo_add_undo_method>`, :ref:`add_do_property<class_UndoRedo_add_do_property>` and :ref:`add_undo_property<class_UndoRedo_add_undo_property>`.
  79. .. _class_UndoRedo_get_current_action_name:
  80. - :ref:`String<class_string>` **get_current_action_name** **(** **)** const
  81. Get the name of the current action.
  82. .. _class_UndoRedo_get_version:
  83. - :ref:`int<class_int>` **get_version** **(** **)** const
  84. Get the version, each time a new action is committed, the version number of the UndoRedo is increased automatically.
  85. This is useful mostly to check if something changed from a saved version.
  86. .. _class_UndoRedo_redo:
  87. - void **redo** **(** **)**
  88. .. _class_UndoRedo_undo:
  89. - void **undo** **(** **)**