{"action":"created","issue":{"url":"https://api.github.com/repos/godotengine/godot/issues/5040","repository_url":"https://api.github.com/repos/godotengine/godot","labels_url":"https://api.github.com/repos/godotengine/godot/issues/5040/labels{/name}","comments_url":"https://api.github.com/repos/godotengine/godot/issues/5040/comments","events_url":"https://api.github.com/repos/godotengine/godot/issues/5040/events","html_url":"https://github.com/godotengine/godot/issues/5040","id":158531327,"number":5040,"title":"Need help completing editor customizable shortcuts!","user":{"login":"reduz","id":6265307,"avatar_url":"https://avatars.githubusercontent.com/u/6265307?v=3","gravatar_id":"","url":"https://api.github.com/users/reduz","html_url":"https://github.com/reduz","followers_url":"https://api.github.com/users/reduz/followers","following_url":"https://api.github.com/users/reduz/following{/other_user}","gists_url":"https://api.github.com/users/reduz/gists{/gist_id}","starred_url":"https://api.github.com/users/reduz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reduz/subscriptions","organizations_url":"https://api.github.com/users/reduz/orgs","repos_url":"https://api.github.com/users/reduz/repos","events_url":"https://api.github.com/users/reduz/events{/privacy}","received_events_url":"https://api.github.com/users/reduz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/godotengine/godot/labels/enhancement","name":"enhancement","color":"44bbff"},{"url":"https://api.github.com/repos/godotengine/godot/labels/junior%20job","name":"junior job","color":"00eeee"},{"url":"https://api.github.com/repos/godotengine/godot/labels/topic:editor","name":"topic:editor","color":"ffdd44"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/godotengine/godot/milestones/5","html_url":"https://github.com/godotengine/godot/milestones/2.1","labels_url":"https://api.github.com/repos/godotengine/godot/milestones/5/labels","id":1449703,"number":5,"title":"2.1","description":"","creator":{"login":"akien-mga","id":4701338,"avatar_url":"https://avatars.githubusercontent.com/u/4701338?v=3","gravatar_id":"","url":"https://api.github.com/users/akien-mga","html_url":"https://github.com/akien-mga","followers_url":"https://api.github.com/users/akien-mga/followers","following_url":"https://api.github.com/users/akien-mga/following{/other_user}","gists_url":"https://api.github.com/users/akien-mga/gists{/gist_id}","starred_url":"https://api.github.com/users/akien-mga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akien-mga/subscriptions","organizations_url":"https://api.github.com/users/akien-mga/orgs","repos_url":"https://api.github.com/users/akien-mga/repos","events_url":"https://api.github.com/users/akien-mga/events{/privacy}","received_events_url":"https://api.github.com/users/akien-mga/received_events","type":"User","site_admin":false},"open_issues":243,"closed_issues":237,"state":"open","created_at":"2015-12-08T11:42:22Z","updated_at":"2016-06-15T06:36:08Z","due_on":null,"closed_at":null},"comments":22,"created_at":"2016-06-05T00:42:12Z","updated_at":"2016-06-15T06:38:19Z","closed_at":null,"body":"Editor shortcuts can now be customized, and there are a new few tools for this, specially the ShortCut resource.\r\n\r\nMost of editor_node.cpp has been converted, but the rest of the editor remains. Here's the global functions that can be used:\r\n\r\n`ED_SHORTCUT(const String& p_path,const String& p_name,uint32_t p_keycode=0);`\r\n\r\nThis defines a new shortcut, which must contain a section/identifier path, a translatable name and a keyboard shortcut. Returns a shortcut object which can be added to a button or to a menu. An example of this from editor_node.cpp:\r\n\r\n\t`p->add_shortcut(ED_SHORTCUT(\"editor/save_scene_as\",TTR(\"Save Scene As..\"),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_AS_SCENE);\r\n`\r\n\r\nMany times, the menus, buttons, etc. are created on the fly, so call this function again on a constructor or at some place where initialization occurs, this way it can always appear in editor settings dialog. Just call it and ignore the return, as it will be cached for next time you call it.\r\n`\r\nED_SHORTCUT(\"editor/save_scene_as\",TTR(\"Save Scene As..\"),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S)\r\n`\r\nOptionally and for simplicity you can simply get the shortcut, but it must have defined as above!\r\n\r\n```\r\nRef<ShortCut> ED_GET_SHORTCUT(const String& p_path);\r\n\r\nusded like:\r\n\r\nsomebutton->set_shortcut( ED_GET_SHORTCUT(\"editor/save_scene_as\") );\r\n```\r\nIn many places, checking for a shortcut is done manually from an unhandled input callback. Generally this is done with a switch(), so it will have to be changed to a sequence of ifs(). In such cases simply define the shortcut as in the code (two samples above ^), then check manually against an InputEvent: \r\n\r\n```\r\nif ( ED_IS_SHORTCUT(\"editor/save_scene_as\") ) {\r\n...\r\n}\r\n```\r\n\r\nI think this is all! Good luck :)\r\n"},"comment":{"url":"https://api.github.com/repos/godotengine/godot/issues/comments/226100782","html_url":"https://github.com/godotengine/godot/issues/5040#issuecomment-226100782","issue_url":"https://api.github.com/repos/godotengine/godot/issues/5040","id":226100782,"user":{"login":"akien-mga","id":4701338,"avatar_url":"https://avatars.githubusercontent.com/u/4701338?v=3","gravatar_id":"","url":"https://api.github.com/users/akien-mga","html_url":"https://github.com/akien-mga","followers_url":"https://api.github.com/users/akien-mga/followers","following_url":"https://api.github.com/users/akien-mga/following{/other_user}","gists_url":"https://api.github.com/users/akien-mga/gists{/gist_id}","starred_url":"https://api.github.com/users/akien-mga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akien-mga/subscriptions","organizations_url":"https://api.github.com/users/akien-mga/orgs","repos_url":"https://api.github.com/users/akien-mga/repos","events_url":"https://api.github.com/users/akien-mga/events{/privacy}","received_events_url":"https://api.github.com/users/akien-mga/received_events","type":"User","site_admin":false},"created_at":"2016-06-15T06:38:19Z","updated_at":"2016-06-15T06:38:19Z","body":"@Paulb23 did script and shader text editors."}}
{"actor":{"display_login":"akien-mga"}}