-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix copy and cut on Safari #3513
Conversation
I also noticed middle clicking a "source code" URL in egui.rs triggers Safari's popup blocker. This is likely the same issue - eframe should run logic headlessly from inside the click handler so it inherits the "user interaction" permissions when processing the click. |
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.
Excellent, thank you!
"cut", | ||
|event: web_sys::ClipboardEvent, runner| { | ||
runner.input.raw.events.push(egui::Event::Cut); | ||
runner.logic(); |
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.
runner.logic(); | |
// In Safari we are only allowed to write to the clipboard during the | |
// event callback, which is why we run the app logic here and now. | |
runner.logic(); |
&document, | ||
"copy", | ||
|event: web_sys::ClipboardEvent, runner| { | ||
runner.input.raw.events.push(egui::Event::Copy); |
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.
runner.input.raw.events.push(egui::Event::Copy); | |
runner.input.raw.events.push(egui::Event::Copy); | |
// In Safari we are only allowed to write to the clipboard during the | |
// event callback, which is why we run the app logic here and now. |
* Closes lampsitter/egui_commonmark#21 Follow-up to #3513 Safari only allows access to the clipboard as response to user action, so we need to take an extra logic step right in the event handler.
* Follow-up to #3621 and #3513 To work around a Safari limitation, we run the app logic in the event handler of copy, cut, and mouse up and down. Previously the output of that frame was discarded, but in this PR it is now saved to be used in the next requestAnimationFrame. The result is noticeable more distinct clicks on buttons (one more frame of highlight) Bonus: also fix auto-save of a sleeping web app
…d guides (#4300) ### What egui 0.24 will fix the bug where coping from Safari was impossible: - emilk/egui#3513 This PR removes the related warnings in the in-app Getting Started guides. - May be blocked by lampsitter/egui_commonmark#21?? - Blocked by #4111 - Fixes #4292 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4300) (if applicable) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/4300) - [Docs preview](https://rerun.io/preview/0a0e58f6c169798c01d1932ecec3fb51cfe6360e/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/0a0e58f6c169798c01d1932ecec3fb51cfe6360e/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
I've tested this on Safari and Chrome on macOS Sonoma 14.0.
Could be improved to only call
event.preventDefault()
ifrunner.logic()
actually performed a copy, but I don't see a way to get that information out with the current API.