RichTextFX icon indicating copy to clipboard operation
RichTextFX copied to clipboard

If typed \n in text, MOUSE_OVER_TEXT_END will be fired just follow MOUSE_OVER_TEXT_BEGIN when hover on character on Linux

Open YangLiu1024 opened this issue 5 years ago • 5 comments


Expected Behavior

Only emit MOUSE_OVER_TEXT_BEGIN when hover on character

Actual Behavior

emit MOUSE_OVER_TEXT_END just follow MOUSE_OVER_TEXT_BEGIN when text contain "\n"

Reproducible Demo

Provide a demo that maintainers of this project can copy, paste, and run to reproduce it immediately.

Use the following template to get started.

public class Bug extends Application {

 public void start(Stage primaryStage) {

    CodeArea codeArea = new CodeArea();
    codeArea.setMouseOverTextDelay(Duration.ofMillis(500));
    Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(codeArea.textProperty());
    codeArea.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_BEGIN, evt -> {
      Point2D pos = evt.getScreenPosition();
      tooltip.show(codeArea, pos.getX(), pos.getY());
    });
    codeArea.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_END, evt -> {
      tooltip.hide();
    });
    primaryStage.setScene(new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400));
    primaryStage.setTitle("Pattern Constrain Demo");
    primaryStage.show();
 }

}

Environment info:

  • RichTextFX Version: <0.9.3>
  • Operating System: <Linux>
  • Java version: <1.8>

YangLiu1024 avatar Mar 14 '19 09:03 YangLiu1024

The problem you are having is because of this line: tooltip.show(codeArea, pos.getX(), pos.getY()); where the tooltip is being shown on exactly the same position as the mouse pointer which then causes MOUSE_OVER_TEXT_END to fire.

To avoid this just add some value to the either getX() or getY() to shift the position of the displayed Tooltip, e.g. tooltip.show( codeArea, pos.getX(), pos.getY() + 10 );

Jugen avatar Mar 14 '19 10:03 Jugen

@Jugen i tried with your propose, but it does not work neither And i change to just print message instead of popup tooltip, the MOUSE_OVER_TEXT_END will be fired just followed MOUSE_OVER_TEXT_BEGIN. And if i remove all the "\n" in text, there is no problem.

YangLiu1024 avatar Mar 15 '19 03:03 YangLiu1024

I can't seem to reproduce the problem on Windows, so maybe this is Linux specific. Can you maybe test on Windows ? Also did this work in the past and is now a new problem with RichTextFX 0.9.3 ?

Jugen avatar Mar 15 '19 11:03 Jugen

yes, there is no problem on windows with 0.9.3. And i test for 0.6.10, there is no problem on both Windows and Linux. So this is a new issue with RichTextFX 0.9.3, and its Linux specific.

YangLiu1024 avatar Mar 16 '19 05:03 YangLiu1024

Ok, I've had a look between the 0.6.10 and 0.9.3 code that fires mouse end and can't see a significant difference.

Can you check if it works with any version after 0.6.10 like in the 0.7.x or 0.8.x series maybe ?

If we can find the last time it worked and then broke then maybe we can fix it. (I hope that the last time it worked wasn't in 0.6.10 because there was a major overhaul between that version and the next.)

Jugen avatar Mar 20 '19 09:03 Jugen