gpt4 book ai didi

JavaFX Web View : custom cursors not working?

转载 作者:行者123 更新时间:2023-12-01 17:36:05 25 4
gpt4 key购买 nike

我尝试让 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不支持该功能吗?其他光标,例如 waitgrab 工作正常。

最佳答案

这只是一个与报价相关的问题。

我将内容行更改为

String content = String.format("<body style=\"cursor: url('%s') 10 10, auto\";>", cursorUrl);

效果很好。

关于JavaFX Web View : custom cursors not working?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61038768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com