Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor defined shortcut access via script. #78072

Closed
ghost opened this issue Jun 10, 2023 · 11 comments
Closed

Editor defined shortcut access via script. #78072

ghost opened this issue Jun 10, 2023 · 11 comments

Comments

@ghost
Copy link

ghost commented Jun 10, 2023

Godot version

v4.0.3.stable.official [5222a99]

System information

Windows 11, AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx 2.10 GHz

Issue description

Is there a way of retrieving the Editor shortcut values stored in the "command palette" ? Only functions that modify are available, none to query the contents ? I see in the source that there is a is_shortcut () method via the EditorSettings singleton that can do this, but it isn't exposed. For plugins that use shortcuts, access to this information ensures they can be updated when the user makes changes in this regard.

Steps to reproduce

N/A

Minimal reproduction project

N/A

@AThousandShips
Copy link
Member

AThousandShips commented Jun 10, 2023

is_shortcut tests it and doesn't retrieve it.

For support questions and help please first turn to the other community channels, this is for bug reporting, not a help desk. I'd argue this is an improvement proposal, best served over at proposals, be sure to follow the instructions.

Edit: can you try EditorInterface.get_editor_settings().shortcuts?

@ghost
Copy link
Author

ghost commented Jun 10, 2023

Actually is_shortcut () tests an InputEvent against a shortcut, eg. "Script Editor/Find" which is exactly what I want. As for get_editor_interface ().get_editor_settings ().shortcuts, I can't find that anywhere. No mention in the documentation.

@AThousandShips
Copy link
Member

AThousandShips commented Jun 10, 2023

Yes, but you asked about retrieving it, and is_shortcut doesn't do that, I'm sorry but you asked for a specific thing and I responded to that specific thing, namely to retrieve shortcuts

I know it's not documented, but it is a property, and I asked if you could test if it works as I'm not by my computer atm, try if that will return a list of shortcuts

In either case I'd suggest opening a proposal for adding this feature as it's not necessarily a bug that it isn't available, and would need some working out of the specifics

@ghost
Copy link
Author

ghost commented Jun 10, 2023

I only wanted to retrieve the property to test against an InputEvent, eg. in _shortcut_input () or one of the other _input () type functions. I tried what you suggested and an error is issued because no "shortcut" property exists. You may be getting confused with the "Shortcuts" TAB in the Editor Settings dialog in the Editor which lists the shortcuts. I just want to test an InputEvent against an Editor shortcut in script.

@AThousandShips
Copy link
Member

No I'm not confusing anything here, I'm talking about a property that exists in this class but not sure if it's accessible in GDScript, try also get("shortcuts")

Then this is probably best served by a proposal to add this functionality to the engine, go ahead and open one if you like, because missing functionality isn't a bug as such

@ghost
Copy link
Author

ghost commented Jun 10, 2023

That returns a dictionary with some shortcuts. Thankyou very much. Might be a good idea to put that in the documentation.

@AThousandShips
Copy link
Member

AThousandShips commented Jun 10, 2023

Agreed, but still room for improvement, so feel free to open a proposal

I'm not sure we should add this property to the documentation as I'm not sure it's safe. There's even a comment with "do not edit" next to it, and it's not exposed so there's probably a reason for that, so adding proper functionality would be better

@AThousandShips
Copy link
Member

This can probably be closed, and a proposal opened for the desired features

@AThousandShips
Copy link
Member

Please open a dedicated proposal for additional functionality, I'd be up for looking into making the implementation myself

However I don't think it's a good idea to expose or direct users to this property especially as it's only partially accessible, and it's not part of the public API so not reliable

@AThousandShips AThousandShips closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2023
@YuriSizov
Copy link
Contributor

I believe this is already covered by godotengine/godot-proposals#2024 and godotengine/godot-proposals#4112, and is going to be resolved either by #58585 or by a new PR that supersedes it.

There are some issues with the implementation of #58585 and I need to find some time to review it for 4.2. But feel free to try and salvage it yourself, addressing the concerns (see latest comments).

@ghost
Copy link
Author

ghost commented Jun 13, 2023

Looking forward to an implementation that provides access to all the Editor shortcuts because get ("shortcuts") only provides 3 shortcuts for some reason and of course, none of which I need for what I am doing. I'll just have to piggyback on another control that uses the shortcut I want until then...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants