File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1717import com .teamdev .jxbrowser .browser .event .ConsoleMessageReceived ;
1818import com .teamdev .jxbrowser .engine .Engine ;
1919import com .teamdev .jxbrowser .js .ConsoleMessage ;
20+ import com .teamdev .jxbrowser .permission .PermissionType ;
21+ import com .teamdev .jxbrowser .permission .callback .RequestPermissionCallback ;
2022import com .teamdev .jxbrowser .ui .KeyCode ;
2123import com .teamdev .jxbrowser .ui .event .KeyPressed ;
2224import com .teamdev .jxbrowser .view .swing .BrowserView ;
@@ -56,6 +58,18 @@ public EmbeddedJxBrowserTab(Engine engine) {
5658 this .engine = engine ;
5759
5860 try {
61+ // Support copying text in the embedded browser to the clipboard. The following was copied from:
62+ // https://teamdev.com/jxbrowser/docs/guides/clipboard/#necessary-permissions
63+ this .engine .permissions ().set (RequestPermissionCallback .class , (params , tell ) -> {
64+ var type = params .permissionType ();
65+ if (type == PermissionType .CLIPBOARD_READ_WRITE
66+ || type == PermissionType .CLIPBOARD_SANITIZED_WRITE ) {
67+ tell .grant ();
68+ } else {
69+ tell .deny ();
70+ }
71+ });
72+
5973 this .browser = engine .newBrowser ();
6074 this .zoom = this .browser .zoom ();
6175 this .browser .settings ().enableTransparentBackground ();
You can’t perform that action at this time.
0 commit comments