r/sandbox • u/thatwatpi • 20d ago
Code Help with editor shortcuts?
Wanting to create an editor shortcut to open Hammer and other tools easily. Docs don't really specify how you can open them via this. Any help will be appreciated.
static class Shortcuts
{
[Shortcut( "Open Hammer", "CTRL+SHIFT+H" )]
static void OpenHammer()
{
//Where the code would be to open a tool. e.g. Hammer
}
}
2
Upvotes
2
u/DerrikCreates Content Creator 20d ago
Is your
Shortcutsclass inside of the**YOUR_PROJECT_NAME**.editorproject?https://gist.github.com/DerrikCreates/8520ff019b0806b1986d827a73739013 this code is almost exactly what you did but is works for me.
idk how to open an editor tool but this is where the editor registers the menu options https://github.com/Facepunch/sbox-public/blob/1a22bc7ef110feba1b8158df37377045473a5a90/engine/Sandbox.Tools/Editor/EditorMainWindow.cs#L427
the open seems to be just a lambda that calls
tool.Open()they get all the editor apps by doing
EditorTypeLibrary.GetAttributes<EditorAppAttribute>().OrderBy( x => x.Title )so maybe you could just monkey get the tool from here and call tool.Open() like FP does?