Files
godot-docs/classes/class_editorcommandpalette.rst
2022-02-01 16:35:13 +01:00

93 lines
5.3 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the EditorCommandPalette.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_EditorCommandPalette:
EditorCommandPalette
====================
**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>`
Godot editor's command palette.
Description
-----------
Object that holds all the available Commands and their shortcuts text. These Commands can be accessed through **Editor > Command Palette** menu.
Command key names use slash delimiters to distinguish sections Example: ``"example/command1"`` then ``example`` will be the section name.
.. tabs::
.. code-tab:: gdscript
var command_palette = get_editor_interface().get_command_palette()
# external_command is a function that will be called with the command is executed.
var command_callable = Callable(self, "external_command").bind(arguments)
command_palette.add_command("command", "test/command",command_callable)
.. code-tab:: csharp
EditorCommandPalette commandPalette = GetEditorInterface().GetCommandPalette();
// ExternalCommand is a function that will be called with the command is executed.
Callable commandCallable = new Callable(this, nameof(ExternalCommand));
commandPalette.AddCommand("command", "test/command", commandCallable)
\ **Note:** This class shouldn't be instantiated directly. Instead, access the singleton using :ref:`EditorInterface.get_command_palette<class_EditorInterface_method_get_command_palette>`.
Properties
----------
+-------------------------+-------------------+------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | dialog_hide_on_ok | ``false`` (overrides :ref:`AcceptDialog<class_AcceptDialog_property_dialog_hide_on_ok>`) |
+-------------------------+-------------------+------------------------------------------------------------------------------------------+
Methods
-------
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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" **)** |
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove_command<class_EditorCommandPalette_method_remove_command>` **(** :ref:`String<class_String>` key_name **)** |
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Method Descriptions
-------------------
.. _class_EditorCommandPalette_method_add_command:
- 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" **)**
Adds a custom command to EditorCommandPalette.
- ``command_name``: :ref:`String<class_String>` (Name of the **Command**. This is displayed to the user.)
- ``key_name``: :ref:`String<class_String>` (Name of the key for a particular **Command**. This is used to uniquely identify the **Command**.)
- ``binded_callable``: :ref:`Callable<class_Callable>` (Callable of the **Command**. This will be executed when the **Command** is selected.)
- ``shortcut_text``: :ref:`String<class_String>` (Shortcut text of the **Command** if available.)
----
.. _class_EditorCommandPalette_method_remove_command:
- void **remove_command** **(** :ref:`String<class_String>` key_name **)**
Removes the custom command from EditorCommandPalette.
- ``key_name``: :ref:`String<class_String>` (Name of the key for a particular **Command**.)
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`