Raspberry Pi无法在JavaFX应用程序中隐藏鼠标光标 [英] Raspberry Pi can't hide mouse cursor in JavaFX application

查看:254
本文介绍了Raspberry Pi无法在JavaFX应用程序中隐藏鼠标光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我为Raspberry Pi 3开发了一个JavaFX应用程序。为了在我的PC上进行开发,我使用的是Ubuntu 16.04.1,OpenJDK 1.8.0_111和OpenJFX 8.0.60。对于Raspberri Pi上的操作,我使用Raspbian Jessie和PIXEL(在控制台模式下启动),OpenJDK 1.8.0_40和OpenJFX 8.0.60。

Currently I develop a JavaFX application for the Raspberry Pi 3. For development on my PC I use Ubuntu 16.04.1, OpenJDK 1.8.0_111 and OpenJFX 8.0.60. For operation on the Raspberri Pi I use Raspbian Jessie with PIXEL (boot in console mode), OpenJDK 1.8.0_40 and OpenJFX 8.0.60.

图形鼠标光标是不必要的,因为用户只应使用触摸屏与应用程序进行交互。此外,鼠标光标很烦人,因为它略微覆盖了屏幕的内容。此外,每当触摸屏幕时,它通过改变其位置来刺激用户。因此,我想在屏幕上隐藏鼠标光标。

A graphical mouse cursor is unnecessary, because the user should only interact with the application using a touch screen. Furthermore the mouse cursor is annoying, because it slightly covers the content of the screen. In addition it irritates the user by changing its position whenever the screen is touched. Therefore I want to hide the mouse cursor on the screen.

在我的电脑上,我可以使用以下代码隐藏鼠标光标:

On my PC I am able to hide the mouse cursor using the following code:

scene.setCursor(Cursor.NONE);

我使用

java -jar MyApp.jar

执行此操作后,setCurser属性最初起作用。但是在触摸屏幕或移动鼠标后,屏幕上会出现默认的鼠标光标。这似乎是一个尚未解决的问题:发表在raspberrypi.org论坛

After doing so the setCurser property works initially. But after touching the screen or moving the mouse the default mouse cursor appears on the screen. This seems to be an unresolved problem: Post on raspberrypi.org forum

OpenJFX Wiki 说:


请注意,Raspberry Pi上JavaFX的默认配置确实如此
不使用X11。相反,JavaFX直接使用显示
帧缓冲和输入设备。所以启动JavaFX时不应该运行X11桌面

Note that the default configuration of JavaFX on the Raspberry Pi does not use X11. Instead JavaFX works directly with the display framebuffer and input devices. So you should not have the X11 desktop running when starting JavaFX.

作为一种解决方法,我该如何隐藏图形在Raspbian Jessie的framebuffer中的鼠标光标?

As a workaround, how can I hide the graphical mouse cursor in the framebuffer on Raspbian Jessie?

推荐答案

我找到了这个bug的解决方法。虽然它在我的应用程序开始时会产生一些闪烁,但在我的情况下是可以接受的。 (另外你可以尝试在程序启动时关闭背光)
这是魔法代码(无法使用几个全屏窗口发现治疗效果)

I've found workaround for this bug. Though it creates some flickering at the start of my application it is acceptable in my case. (Also you could try to turn backlight off during program start ) Here is the magic code(the cure effect was discovered accidentally working with several full screen windows)

private void fixMouse(Stage primaryStage)
    {
        Platform.runLater(()->{
            //Show mouse cursor
            Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();

            robot.mouseMove(790,470);
            robot.destroy();

            //Show fullscreen dialog
            final Stage dialog = new Stage();
            dialog.initModality(Modality.APPLICATION_MODAL);
            dialog.initOwner(primaryStage);

            StackPane dialogLayout = new StackPane();
            dialog.setFullScreen(true);
            dialog.setResizable(false);
            dialog.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

            Scene dialogScene = new Scene(dialogLayout, 0, 0);
            dialogScene.setCursor(Cursor.NONE);
            dialogScene.setFill(Color.BLACK);
            dialogLayout.setBackground(Background.EMPTY);

            dialog.setScene(dialogScene);
            dialog.show();

            // Auto close the dialog
            Platform.runLater(()->{
                        dialog.close();
                        primaryStage.setFullScreen(true);
                    });
            });
    }

这篇关于Raspberry Pi无法在JavaFX应用程序中隐藏鼠标光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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