class_editorcommandpalette.rst 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 EditorCommandPalette.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_EditorCommandPalette:
  6. EditorCommandPalette
  7. ====================
  8. **Inherits:** :ref:`ConfirmationDialog<class_ConfirmationDialog>` **<** :ref:`AcceptDialog<class_AcceptDialog>` **<** :ref:`Window<class_Window>` **<** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Godot editor's command palette.
  10. Description
  11. -----------
  12. Object that holds all the available Commands and their shortcuts text. These Commands can be accessed through **Editor > Command Palette** menu.
  13. Command key names use slash delimiters to distinguish sections Example: ``"example/command1"`` then ``example`` will be the section name.
  14. .. tabs::
  15. .. code-tab:: gdscript
  16. var command_palette = get_editor_interface().get_command_palette()
  17. # external_command is a function that will be called with the command is executed.
  18. var command_callable = Callable(self, "external_command").bind(arguments)
  19. command_palette.add_command("command", "test/command",command_callable)
  20. .. code-tab:: csharp
  21. EditorCommandPalette commandPalette = GetEditorInterface().GetCommandPalette();
  22. // ExternalCommand is a function that will be called with the command is executed.
  23. Callable commandCallable = new Callable(this, nameof(ExternalCommand));
  24. commandPalette.AddCommand("command", "test/command", commandCallable)
  25. \ **Note:** This class shouldn't be instantiated directly. Instead, access the singleton using :ref:`EditorInterface.get_command_palette<class_EditorInterface_method_get_command_palette>`.
  26. Properties
  27. ----------
  28. +-------------------------+-------------------+------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | dialog_hide_on_ok | ``false`` (overrides :ref:`AcceptDialog<class_AcceptDialog_property_dialog_hide_on_ok>`) |
  30. +-------------------------+-------------------+------------------------------------------------------------------------------------------+
  31. Methods
  32. -------
  33. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`add_command<class_EditorCommandPalette_method_add_command>` **(** :ref:`String<class_String>` command_name, :ref:`String<class_String>` key_name, :ref:`Callable<class_Callable>` binded_callable, :ref:`String<class_String>` shortcut_text="None" **)** |
  35. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`remove_command<class_EditorCommandPalette_method_remove_command>` **(** :ref:`String<class_String>` key_name **)** |
  37. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. Method Descriptions
  39. -------------------
  40. .. _class_EditorCommandPalette_method_add_command:
  41. - void **add_command** **(** :ref:`String<class_String>` command_name, :ref:`String<class_String>` key_name, :ref:`Callable<class_Callable>` binded_callable, :ref:`String<class_String>` shortcut_text="None" **)**
  42. Adds a custom command to EditorCommandPalette.
  43. - ``command_name``: :ref:`String<class_String>` (Name of the **Command**. This is displayed to the user.)
  44. - ``key_name``: :ref:`String<class_String>` (Name of the key for a particular **Command**. This is used to uniquely identify the **Command**.)
  45. - ``binded_callable``: :ref:`Callable<class_Callable>` (Callable of the **Command**. This will be executed when the **Command** is selected.)
  46. - ``shortcut_text``: :ref:`String<class_String>` (Shortcut text of the **Command** if available.)
  47. ----
  48. .. _class_EditorCommandPalette_method_remove_command:
  49. - void **remove_command** **(** :ref:`String<class_String>` key_name **)**
  50. Removes the custom command from EditorCommandPalette.
  51. - ``key_name``: :ref:`String<class_String>` (Name of the key for a particular **Command**.)
  52. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  53. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  54. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  55. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  56. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  57. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`