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

Use macOS shortcuts in LineEdit and TextEdit when the host platform is macOS on HTML5 #3754

Closed
milanvarady opened this issue Jan 4, 2022 · 8 comments

Comments

@milanvarady
Copy link

Describe the project you are working on

Not anything in particular

Describe the problem or limitation you are having in your project

Shortcuts in the TextEdit and LineEdit nodes such as Command+C copy, Command+V paste, CTRL+E go to end of the line are not working on macOS when exporting for the web. They work when run on the macOS export, but when exporting for web, copying as an example works with the Control key and not with the Command key, which is pretty annoying if you are used to using the Command key for almost everything.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Make it so these shortcuts work on the web as well.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

If a macOS user agent is detected, Godot should use these shortcuts.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I guess you could implement these for your self, but it would take time, especially if you want to include all of the shortcuts.

Is there a reason why this should be core and not an add-on in the asset library?

This would improve the web export on Mac devices.

@Calinou Calinou changed the title TextEdit macOS shortcuts don't work on HTML export Use macOS shortcuts in LineEdit and TextEdit when the host platform is macOS on HTML5 Jan 4, 2022
@Faless
Copy link

Faless commented Jan 5, 2022

Currently Godot handles the differences at compile time via a APPLE_STYLE_KEYS switch.
Supporting different shortcuts in the HTML5 platform for OSX would mean change the behaviour to handle those at runtime.

@YuriSizov
Copy link
Contributor

We moved away from preprocessor directives in the editor and use platform suffixes now. godotengine/godot#51280

So probably should do the same for scene files. Then it should be possible to hack something for the html platform to detect native platform.

@Faless
Copy link

Faless commented Jan 5, 2022

Oh I see, it's a bit worse then I expected actually, we'll have to review the OSX_ENABLED flag too.
What I was referring to is not in scene but in core:
https://github.com/godotengine/godot/blob/master/core/input/input_event.h#L114
https://github.com/godotengine/godot/blob/master/core/input/input_event.cpp#L280

@Calinou
Copy link
Member

Calinou commented Jan 5, 2022

Oh I see, it's a bit worse then I expected actually, we'll have to review the OSX_ENABLED flag too. What I was referring to is not in scene but in core: godotengine/godot@master/core/input/input_event.h#L114 godotengine/godot@master/core/input/input_event.cpp#L280

See also godotengine/godot#47619 (although this was done before the input refactoring).

@jasonwinterpixel
Copy link

jasonwinterpixel commented Feb 14, 2022

We have also encountered this issue. I think the root error is here:

#ifdef APPLE_STYLE_KEYS
	union {
		bool command;
		bool meta; //< windows/mac key
	};

	bool control;
#else
	union {
		bool command; //< windows/mac key
		bool control;
	};
	bool meta; //< windows/mac key

#endif

If the union is removed, then the system can begin to start to detect and alter behaviour based on platform. A function can be introduced get_command_or_control() (or something better named) that returns true if its an apple platform, and command is pressed, or control is pressed. That function can be used across the system where get_command() and get_control() are used.

It is suprising to me that get_command() is used more frequently across Godot's code base than get_control() is. I imagine that the developers who wrote those lines are mac users?

The refactor towards a runtime check of platform will require careful examination of each use of get_command() and get_control() to make sure they are not within #ifdef APPLE_STYLE_KEYS.

A simple solution until a refactor can be done is to use get_meta() in line_edit.cpp (and text_edit.cpp) to enable command+c/v/etc.

@RPicster
Copy link

Will this issue move forward, is there anything planned?
Right now on my work it is the reason for discussions to drop Godot entirely for the web and return to a "normal" web stack.

For me this is beyond frustrating :(

@YuriSizov
Copy link
Contributor

This cannot really be addressed in 3.x because the root of the issue is in how shortcuts are bound for each platform. In 4.0 however we can have multiple shortcuts and in fact the editor ones are now modified using feature suffixes and not precompile instructions. So it should be solvable for Godot 4. But I don't think anyone volunteered to work in this yet.

@akien-mga
Copy link
Member

Implemented by godotengine/godot#91887.

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

7 participants