Skip to content
0.2.0-dev Download ZIP
51 lines ·2.7 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="EditorCommandPalette" inherits="ConfirmationDialog" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Godot editor's command palette.
5 </brief_description>
6 <description>
7 Object that holds all the available Commands and their shortcuts text. These Commands can be accessed through [b]Editor &gt; Command Palette[/b] menu.
8 Command key names use slash delimiters to distinguish sections, for example: [code]"example/command1"[/code] then [code]example[/code] will be the section name.
9 [codeblocks]
10 [gdscript]
11 var command_palette = EditorInterface.get_command_palette()
12 # external_command is a function that will be called with the command is executed.
13 var command_callable = Callable(self, "external_command").bind(arguments)
14 command_palette.add_command("command", "test/command",command_callable)
15 [/gdscript]
16 [csharp]
17 EditorCommandPalette commandPalette = EditorInterface.Singleton.GetCommandPalette();
18 // ExternalCommand is a function that will be called with the command is executed.
19 Callable commandCallable = new Callable(this, MethodName.ExternalCommand);
20 commandPalette.AddCommand("command", "test/command", commandCallable)
21 [/csharp]
22 [/codeblocks]
23 [b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton using [method EditorInterface.get_command_palette].
24 </description>
25 <tutorials>
26 </tutorials>
27 <methods>
28 <method name="add_command">
29 <return type="void" />
30 <param index="0" name="command_name" type="String" />
31 <param index="1" name="key_name" type="String" />
32 <param index="2" name="binded_callable" type="Callable" />
33 <param index="3" name="shortcut_text" type="String" default="&quot;None&quot;" />
34 <description>
35 Adds a custom command to EditorCommandPalette.
36 - [param command_name]: [String] (Name of the [b]Command[/b]. This is displayed to the user.)
37 - [param key_name]: [String] (Name of the key for a particular [b]Command[/b]. This is used to uniquely identify the [b]Command[/b].)
38 - [param binded_callable]: [Callable] (Callable of the [b]Command[/b]. This will be executed when the [b]Command[/b] is selected.)
39 - [param shortcut_text]: [String] (Shortcut text of the [b]Command[/b] if available.)
40 </description>
41 </method>
42 <method name="remove_command">
43 <return type="void" />
44 <param index="0" name="key_name" type="String" />
45 <description>
46 Removes the custom command from EditorCommandPalette.
47 - [param key_name]: [String] (Name of the key for a particular [b]Command[/b].)
48 </description>
49 </method>
50 </methods>
51</class>