-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Conversation
Makes sense. I'm not fond of the Yoda-speak names for |
There was a problem hiding this 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.
if (godot_java->has_has_clipboard()) { | ||
return godot_java->has_clipboard(); | ||
} else { | ||
return DisplayServer::clipboard_has(); | ||
} |
There was a problem hiding this comment.
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.
e3012f9
to
314f309
Compare
Thanks! |
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: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.