JavaFX WebView:自定义游标不起作用? [英] JavaFX WebView: custom cursors not working?

查看:114
本文介绍了JavaFX WebView:自定义游标不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让css自定义游标与标记中的Java WebView一起使用,但无济于事.

I tried to get css custom cursors to work with Java WebView within a tag, to no avail.

例如:

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周围的引号.似乎什么都没用.

I also tried to replace the .png cursor by a .cur file, as well as remove the quotes around the url. Nothing seems to work.

WebView不支持该功能吗?其他光标,例如waitgrab都可以正常工作.

Does WebView not support the feature? Other cursor such as wait and grab work fine.

推荐答案

这仅仅是与引号相关的问题.

It was a mere problem related to quotes.

我将内容行更改为

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

效果很好.

这篇关于JavaFX WebView:自定义游标不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆