“unknown protocol: data” when using data URIs in IMG tags displayed by JavaFX WebView

亡梦爱人 提交于 2019-12-04 16:40:10

As already mentioned in my comment, it's an open bug in JavaFX: https://bugs.openjdk.java.net/browse/JDK-8160597

But it seems I have found a workaround. I just had to add three listeners to the web view for the drag events which do nothing at all, not even consume the event. After that text selection in the web view still worked and the exception while dragging the images vanished:

webview {
  setOnDragEntered {
  }

  setOnDragOver {
  }

  setOnDragExited {
  }
}

This is Kotlin code, as I'm developing in Kotlin with TornadoFX (a JavaFX wrapper). I'm guessing in Java the code would look pretty similar. Just call the three set methods directly on the web view object and add an anonymous class with an empty handle method. Or use an empty lambda expression, if you are using newer Java versions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!