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

Added ability to override shortcut definitions for OSX (remove preprocessor defines) #51280

Conversation

EricEzaM
Copy link
Contributor

@EricEzaM EricEzaM commented Aug 5, 2021

May help with godotengine/godot-docs#3333 cc @pycbouh

No more OSX_ENABLED preprocessor define checks when defining default editor shortcuts. Just add a call to ED_SHORTCUT_OVERRIDE with the corresponding feature you want the override to be for (e.g. "macOS"), and the new event.

@EricEzaM EricEzaM requested a review from a team as a code owner August 5, 2021 13:37
@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch from 21770cb to 0dbef6d Compare August 5, 2021 13:38
@EricEzaM EricEzaM requested a review from a team August 5, 2021 13:44
@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch from 0dbef6d to cb93ef8 Compare August 5, 2021 23:37
@EricEzaM
Copy link
Contributor Author

EricEzaM commented Aug 5, 2021

@akien-mga Ok, I changed it. I think it is right but it will need testing on macOS of course.

@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch from cb93ef8 to 2daddee Compare August 6, 2021 07:22
@YuriSizov
Copy link
Contributor

YuriSizov commented Aug 6, 2021

So, to me changes look sane and clear, but I wouldn't dare to approve this without testing it on a Mac first, which I unfortunately cannot do 🙃

Having to supply shortcut names to the overrides may be a bit excessive but we can always address this in a separate PR without breaking anything.

@YuriSizov YuriSizov requested a review from a team August 6, 2021 13:32
editor/editor_node.cpp Outdated Show resolved Hide resolved
@EricEzaM
Copy link
Contributor Author

EricEzaM commented Aug 8, 2021

Ok, my previous implementation was actually wrong and would not work properly, lol. I think I was rushing my thinking a bit.

I have tested the new version on Windows, by adding a shortcut override with "Windows" as the feature. This worked correctly:

	ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11);
	ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "macOS", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F);
	ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "Windows", KEY_MASK_CTRL | KEY_KP_1);

The shortcut was correctly listed as Ctrl + KP1 in editor settings, and the shortcut worked when pressed.

@pycbouh Additionally with this, the shortcut name is no longer repeated. It should now also be much easier to parse the codebase with a Python file (or similar), looking for ED_SHORTCUT_OVERRIDE to automatically construct the list of editor shortcuts.

@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch from 2daddee to d66a8e0 Compare August 8, 2021 04:20
@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch 2 times, most recently from 6c7d358 to 25e9d78 Compare September 21, 2021 14:04
@EricEzaM
Copy link
Contributor Author

EricEzaM commented Sep 21, 2021

Ok, I think it is in a mergeable state now. I have not tested on macos, but really it should not matter, it all works on the Feature system now. So doing either of the following should not matter:

// macos
ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "macos", KEY_MASK_CTRL | KEY_KP_1);
// windows
ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "windows", KEY_MASK_CTRL | KEY_KP_1);

Tested on windows and it works fine. If you are on Linux you can pull this PR and add an ED_SHORTCUT_OVERRIDE somewhere with the feature being linuxbsd and it should work just as well.

@EricEzaM EricEzaM force-pushed the shortcut-remove-preprocessor-defines-add-overrides branch from 25e9d78 to 6b65092 Compare September 21, 2021 14:10
@akien-mga akien-mga merged commit f144b33 into godotengine:master Sep 21, 2021
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants