Merge pull request #102889 from ryevdokimov/add-editorsettings-shortcuts
Add ability to add new EditorSettings shortcuts
This commit is contained in:
@ -70,6 +70,33 @@
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_shortcut">
|
||||
<return type="void" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<param index="1" name="shortcut" type="Shortcut" />
|
||||
<description>
|
||||
Adds a [param shortcut] whose path is specified by [param path].
|
||||
The [param path] determines how the shortcut is organized and displayed in the editor's shortcut settings. The path format affects the display as follows:
|
||||
- [code]"name"[/code] (no slash): Creates a category named [code]name[/code] with the shortcut displayed as [code]name[/code].
|
||||
- [code]"category/name"[/code] (single slash): Displays as [code]name[/code] in the [code]category[/code] section.
|
||||
- [code]"category/name/extra"[/code] (multiple slashes): Extra path components are ignored, so this behaves the same as [code]"category/name"[/code].
|
||||
[b]Note:[/b] Shortcuts are only saved to the editor settings if they differ from their original/default state. This means empty shortcuts that were originally empty will not persist between editor sessions and must be re-added. If a shortcut with the same [param path] already exists, this method will update it with the new [param shortcut] instead of creating a duplicate.
|
||||
[codeblock]
|
||||
# Add a custom shortcut for a plugin action.
|
||||
var my_shortcut = Shortcut.new()
|
||||
var input_event = InputEventKey.new()
|
||||
input_event.keycode = KEY_F5
|
||||
input_event.ctrl_pressed = true
|
||||
my_shortcut.events.append(input_event)
|
||||
|
||||
# This will appear under the "My Plugin" category as "Reload Data".
|
||||
EditorInterface.get_editor_settings().add_shortcut("my_plugin/reload_data", my_shortcut)
|
||||
|
||||
# This will appear under the "Test Action" category as "Test Action".
|
||||
EditorInterface.get_editor_settings().add_shortcut("test_action", my_shortcut)
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="check_changed_settings_in_group" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="setting_prefix" type="String" />
|
||||
@ -118,6 +145,19 @@
|
||||
Returns the value of the setting specified by [param name]. This is equivalent to using [method Object.get] on the EditorSettings instance.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_shortcut" qualifiers="const">
|
||||
<return type="Shortcut" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Returns the shortcut specified by [param path]. Tries to find a built-in action if no shortcut with the provided path is found in the shortcut list. If found, adds it to the list and returns it, otherwise returns [code]null[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_shortcut_list">
|
||||
<return type="PackedStringArray" />
|
||||
<description>
|
||||
Returns the list of stored shortcut paths.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_setting" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="name" type="String" />
|
||||
@ -125,6 +165,21 @@
|
||||
Returns [code]true[/code] if the setting specified by [param name] exists, [code]false[/code] otherwise.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_shortcut" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the shortcut specified by [param path] exists, [code]false[/code] otherwise.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_shortcut" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<param index="1" name="event" type="InputEvent" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the shortcut specified by [param path] matches the event specified by [param event], [code]false[/code] otherwise.
|
||||
</description>
|
||||
</method>
|
||||
<method name="mark_setting_changed">
|
||||
<return type="void" />
|
||||
<param index="0" name="setting" type="String" />
|
||||
@ -132,6 +187,13 @@
|
||||
Marks the passed editor setting as being changed, see [method get_changed_settings]. Only settings which exist (see [method has_setting]) will be accepted.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_shortcut">
|
||||
<return type="void" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Removes the shortcut specified by [param path].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_builtin_action_override">
|
||||
<return type="void" />
|
||||
<param index="0" name="name" type="String" />
|
||||
|
||||
Reference in New Issue
Block a user