FXMisc / RichTextFX

Rich-text area for JavaFX
BSD 2-Clause "Simplified" License
1.21k stars 236 forks source link

CodeArea horizontal scrollbar not working #210

Closed msarmc closed 7 years ago

msarmc commented 8 years ago

Tomas, I am using a CodeArea in a Dialog. When there is no vertical scrollbar the horizontal scrollbar does not work. I modified JavaKeywordsAsync to demonstrate this. See the attached txt file (it wouldn't let me add a .java file) ScrollBarTest.txt

Thanks, Mike

TomasMikula commented 8 years ago

Hi Mike,

thanks, I can confirm the bug. It is actually reproducible with the demos, Dialog does not make any difference. I assume you are using the latest sources, because I cannot reproduce the bug with the latest released version 0.6.10.

msarmc commented 8 years ago

Tomas,

That’s curious. I ran JavaKeywordsAsync to see if it had the problem but it didn’t. Maybe it is because I let it open at its default width of 600 instead of sizing it down so a horizontal scrollbar would be needed. If 0.6.10 doesn't have the bug I'll try that version.

I am using code I downloaded Nov 16th.

Thanks, Mike

msarmc commented 8 years ago

Tomas,

I changed to use 0.6.10. This corrected the problem in one dialog. In the other dialog the horizontal scrollbar still did not work. In the second case CodeArea is in a SplitPane.

Mike

msarmc commented 8 years ago

I apologize. One more thing. I should have checked this before the previous comment. The vertical scroll bar does not work either when in a SplitPane.

TomasMikula commented 8 years ago

Does it only happen in a Dialog, or whenever in SplitPane?

msarmc commented 8 years ago

I only tested in a Dialog. If I have time later today I'll test it in a SplitPane without using a dialog.

msarmc commented 8 years ago

Using the snapshot I downloaded Nov 16 I tested using a SplitPane not in a dialog. The horizontal scroll bar does not work if there is no vertical scroll bar. If there is a vertical scroll bar both work.

TomasMikula commented 8 years ago

Thanks, but I think we already established that there is a problem in the snapshot, regardless of the Dialog. I was interested to hear about the problem with the 0.6.10 version.

msarmc commented 8 years ago

My apologies. When using 0.6.10 the horizontal scroll bar seems to work fine with the vertical scroll bar when in a SplitPane (and not in a Dialog)

JordanMartinez commented 8 years ago

Am I understanding this correctly? You downloaded the then-current snapshot version on Nov 16 (which occurred a few days before we de-skinned StyledTextArea). The problem you found was that, when a CodeArea is placed inside a SplitPane and its vertical scroll bar is not showing, the horizontal scroll bar doesn't work (i.e., scrolling horizontally doesn't work / dragging the bar doesn't scroll its content horizontally). Is that correct?

JordanMartinez commented 8 years ago

If so, then this problem no longer occurs. I've taken your example and modified it slightly as shown by // --- explanation of change comments. See the following code. ScrollText-Dec 28 Snapshot.txt

msarmc commented 8 years ago

Thanks Jordan!

msarmc commented 8 years ago

Sorry, didn't mean to close this.

isjns commented 8 years ago

Not sure if this issue is considered solved. But I can confirm that it still exists in richtextfx-fat-0.7-M2, and the CodeArea does not have to be placed inside a SplitPane.

I've attached a demo class reproducing the issue. CodeAreaTest.txt

Tested on Windows 8.1 with

java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
JordanMartinez commented 8 years ago

@isjns I tested out your code using the mouse to scroll horizontally and by clicking and moving the scrollbar. It worked fine for me. I'm on Linux with

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
MichelMunoz commented 8 years ago

I confirm the problem, I copy-pasted the code of @isjns then ran it : horizontal scrollbar does not work (win 7 64, jdk 1.8.0_91) see creen capture below :

capture2

isjns commented 8 years ago

Found another similar bug when I used CodeArea for another document. Instead of the horizontal scrollbar not working at all, it works to some extent. When you start dragging the scrollbar from left to right, it slows down more and more as you get closer to the right. Then the scrollbar "jumps" to its rightmost position, but some text is still hidden to the right. See this attached demo class: CodeAreaTest2.txt

Tested on Windows 8.1 with

java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

The problem also occurs if I use a StyleClassedTextArea instead, but only if I manually set the font on it (??).

Both this and my previous issue uses the VirtualizedScrollPane by the way. So I'm not sure if we can say that it's an issue with the "CodeArea horizontal scrollbar" or with if it is an issue with VirtualizedScrollPane.

JordanMartinez commented 8 years ago

@isjns I tested your code and didn't have that issue. The scrollbar moved smoothly at a constant rate.

isjns commented 8 years ago

@JordanMartinez Still on Linux I guess? The bug seems to be Windows specific. Tested it on Windows 7 SP1 with Java 8u92 as well, with the same result as in Windows 8.1.

jplwill commented 7 years ago

I'm seeing this on OS X using richtextfx-fat-0.7-M2.jar and the StyleClassedTextArea in a split pane. I'm still investigating, but it doesn't appear to be a purely Windows problem.

jplwill commented 7 years ago

Same behavior: if the Vertical Scroll Bar is visible, horizontal scrolling works fine. I tried setVBarPolicy(ALWAYS); that didn't fix the problem. The StyleClassedTextArea actually has to have enough content to scroll vertically before horizontal scrolling will work.

synth3 commented 7 years ago

I am having the same problem on Windows 7, Java 8u102: The horizontal scrollbar of a StyleClassedTextArea inside of a VirtualizedScrollPane does not work (dragging or clicking on the scrollbar does not change the horizontal scroll) independent of the presence of an vertical scrollbar. (Just as shown in the screen capture of @MichelMunoz )

Scrolling is essential for a text area and Windows is a widely used operating system so this is a major bug.

Where do I have to look to find the cause? Is there something I can try to work around this?

eckig commented 7 years ago

Is anyone looking into this issue, as I am currently running into the same problems (on Windows)?

This is reproducible:

  1. Demo RichText.java
  2. Run on Windows
  3. Insert one long line of text as the sole content
  4. Try to make use of the horizontal scrollbar? On my machine this does not work

Alternatively any hints on how to investigate this would be much appreciated, too.

synth3 commented 7 years ago

Finally I was able to find the issue:

jplwill commented 7 years ago

Excellent! I'll keep an eye out.

JFormDesigner commented 7 years ago

I can confirm what @synth3 wrote: horizontal scrollbar works with current Flowless master.

@TomasMikula could you please make a 0.5.2 release of Flowless to fix the horizontal scrollbar of RichTextFX?

JordanMartinez commented 7 years ago

Just FYI, if you're using Gradle, you should be able to update your build.gradle file to the following as a temporary workaround until Tomas makes another release:

repositories {
    maven {
        url "https://jitpack.io"
    }
}
dependencies {
    compile 'com.github.TomasMikula:Flowless:a2da8f732c9450ed4576bab80ad4e7084d70d9f0'

    // exclude Flowless in RichTextFX dependency
    compile (group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.7-M3') {
        exclude group: "org.fxmisc.flowless", module: "flowless"
    }
}

I have not tested this code personally, but if I'm following the directions for Jitpack correctly, this should work. Note: I'm using the commit hash, not the branch-SNAPSHOT version, so this should work even if additional work is done on Flowless.

JordanMartinez commented 7 years ago

@TomasMikula Can you make a new Flowless release? Then we could make a release here with the newer changes as well.

robross0606 commented 7 years ago

I'm confused by the suggestion to exclude "flowless". At that point, VirtualizedScrollPane is no longer available and there are no scrollbars at all.

jplwill commented 7 years ago

I believe it's excluding the current release of "flowless" in favor of a snapshot of "flowless" that has the desired fix.

robross0606 commented 7 years ago

That's not what happens unless I also specify that I want flowless separately. If you exclude flowless and nothing else specifies it as a dependency, it is excluded completely. If I need to specify it separately, what version works?

jplwill commented 7 years ago

I'm not a Gradle user: but isn't that what the first "compile" statement in the Gradle spec does? It appears to be making a particular snapshot of "flowless" a dependency of your app, while removing it from compilation as a dependency of "richtextfx". So you get a copy, you just don't get the version "richtextfx" was expecting.

robross0606 commented 7 years ago

Ahhh... totally missed that line in the example. My bad. Thanks!

JordanMartinez commented 7 years ago

@jplwill @robross0606 Yeah, that's exactly what that line does. You'll see the same thing in the richtextfx module's build.gradle file as the version of Flowless that RTFX used at one time used an older version of ReactFX than what RTFX uses, causing an issue when figuring out which version to use in RTFX. Since that was Flowless' only dependency, we simply excluded it, though it should be refactored to only exclude the ReactFX dependency should Flowless ever need another dependency.

TomasMikula commented 7 years ago

Flowless 0.5.2 released. Thanks for finding the problem!

TomasMikula commented 7 years ago

Might take a few minutes before it appears on Maven Central.

jplwill commented 7 years ago

Thanks!

JordanMartinez commented 7 years ago

Closed by #445.