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

Add DisplayServer.clipboard_has() to check clipboard content #56949

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

timothyqiu
Copy link
Member

The current way to check if there is anything to paste is to compare clipboard_get() result with an empty string. However, on Android 12 and higher, the system usually shows a toast message when the app fetches the clipboard content:

Godot Engine pasted from your clipboard

This is confusing & annoying if the user just want to check if there is anything to paste in order to update the UI.

This PR adds a clipboard_has() method that checks clipboard content existence on Android without triggering the toast, and it simply returns !clipboard_get().is_empty() on other platforms.

@akien-mga
Copy link
Member

Makes sense.

I'm not fond of the Yoda-speak names for clipboard_ methods but that's not directly related to this change :)

Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I just added one minor feedback and it should be good to merge.

Comment on lines +102 to +106
if (godot_java->has_has_clipboard()) {
return godot_java->has_clipboard();
} else {
return DisplayServer::clipboard_has();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this pattern is already in the code, but it seems incorrect to me as the default method implementation prints out a not supported warning, which is not the case in this scenario.

No actions needed on your part, I may just revisit this logic later and clean it up.

@akien-mga akien-mga merged commit b6cb366 into godotengine:master Jan 20, 2022
@akien-mga
Copy link
Member

Thanks!

@timothyqiu timothyqiu deleted the has-clipboard branch January 20, 2022 11:39
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.

3 participants