File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,13 @@ fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
174174/// Set the clipboard text.
175175fn set_clipboard_text ( s : & str ) {
176176 if let Some ( window) = web_sys:: window ( ) {
177+ if !window. is_secure_context ( ) {
178+ log:: error!(
179+ "Clipboard is not available because we are not in a secure context. \
180+ See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
181+ ) ;
182+ return ;
183+ }
177184 let promise = window. navigator ( ) . clipboard ( ) . write_text ( s) ;
178185 let future = wasm_bindgen_futures:: JsFuture :: from ( promise) ;
179186 let future = async move {
Original file line number Diff line number Diff line change @@ -1439,6 +1439,10 @@ impl Context {
14391439 ///
14401440 /// Empty strings are ignored.
14411441 ///
1442+ /// Note that in wasm applications, the clipboard is only accessible in secure contexts (e.g.,
1443+ /// HTTPS or localhost). If this method is used outside of a secure context, it will log an
1444+ /// error and do nothing. See <https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts>.
1445+ ///
14421446 /// Equivalent to:
14431447 /// ```
14441448 /// # let ctx = egui::Context::default();
You can’t perform that action at this time.
0 commit comments