Help

#373 Avoid trouble with horizontal scrolling

I understand that Java currently makes it (practically) impossible to do horizontal scrolling properly, so this instead makes horizontal scrolling do nothing, instead of acting similar to a click, and thus messing with the caret position or worse (which I find quite annoying, and is hard to avoid on a touchpad).

The way it does this is by starting the mousePressed and mouseReleased handlers with a check for which mouse button was pressed/released, and if this was no button at all, simply returns instead of doing anything, just as if the events never occurred at all.

I haven't comrehensively tested or checked that this does not break anything, but it seems odd to me that anything should depend on mouse clicks with no button, and I haven't seen any side effects so far.

Well, I use two-finger scrolling on my touchpad, and have both vertical (up-down) and horizontal (left-right) scrolling enabled, in part because my screen is fairly small. This works quite well in most programs, even if there's no sideways scrolling available, vertical scrolling works just fine.

However, in jEdit without this patch, when I have a long document open and scroll vertically, it also reacts to the slight horizontal scrolling that is hard to avoid (moving two fingers perfectly for vertical scrolling is difficult, especially if the touchpad isn't quite aligned with my hand). When this happens, jEdit acts basically as if I had clicked the left mouse button, moving the caret to a new position in the buffer and clearing the selection. This quickly gets to be annoying.

As mentioned, the patch fixes this behaviour, making jEdit ignore the horizontal scroll events. I've been using jEdit with the patch since I first added it here, and haven't noticed any side effects. (In fact, I had pretty much forgotten all about it until your comment...)

I recently switched distro, and hence reinstalled jEdit, now version 4.5 - and found that this problem still exists. The slightest horizontal scrolling is still treated as if I clicked a mouse button in that location.

So, I checked out the 4.5.x branch from svn (help/about now identifies it as 4.5.1), applied the attached patch (it still applies cleanly), and built it - and the behaviour was fixed again.

It's a rather simple patch, really - do you have any specific objections to it that I might address? Or other reasons not to include it?