java - JavaFX WebView:自定义光标不起作用?
问题描述
我试图让 css 自定义光标在标签中与 Java WebView 一起使用,但无济于事。
例如:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX WebView Example");
WebView webView = new WebView();
String cursorUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Pixel_51_icon_cursor_click_top_right.svg/36px-Pixel_51_icon_cursor_click_top_right.svg.png";
String content = String.format("<body style=cursor: url('%s'), auto;>", cursorUrl);
content = content + "<br>some text<br> a link: http://google.com </body>";
System.out.println(content);
webView.getEngine().loadContent(content);
VBox vBox = new VBox(webView);
Scene scene = new Scene(vBox, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
它只显示常规光标。
我还尝试用 .cur 文件替换 .png 光标,并删除 url 周围的引号。似乎没有任何效果。
WebView 不支持该功能吗?其他光标,如wait
和grab
工作正常。
解决方案
这只是与报价有关的问题。
我将内容行更改为
String content = String.format("<body style=\"cursor: url('%s') 10 10, auto\";>", cursorUrl);
它工作得很好。
推荐阅读
- c# - EF6:调用 ExecuteSqlCommand 后 DbContext.Database.Connection.ConnectionString 发生变化
- opencv - SURF_CUDA 每次执行计算不同的关键点
- haskell - 如何告诉haskell堆栈使用已安装的包?
- swift - 我们如何从 UITextView 中的选定文本中获取整个文本?
- java - 发送消息后如何发送客户端自动响应?
- javascript - 密钥未在 javascript 对象中设置
- amazon-web-services - 是否可以在 AWS 上使用 hostgator 域
- google-cloud-platform - 限制 GCE 中的可用实例类型?
- drools - 来自 kie-server 的 FAILURE 回答(使用 kie-server-showcase 和 business-central-workbench-showcase)
- javascript - NodeJS 写流