JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.15k stars 1.17k forks source link

Horizontal scroll doesn't work on Linux #2528

Closed fourlastor closed 1 month ago

fourlastor commented 1 year ago

The following code snippet (100 boxes that should scroll horizontally) doesn't respond to mouse/touchpad scrolling:

Window(onCloseRequest = ::exitApplication) {
    Row(modifier = Modifier.fillMaxSize().horizontalScroll(rememberScrollState())) {
        repeat(100) {
            Box(modifier = Modifier.height(40.dp).width(40.dp).padding(4.dp).background(Color.LightGray))
        }
    }
}

Vertical scrolling (a Column with .verticalScroll(rememberScrollState())) works correctly (it scrolls when using a scrollwheel/touchpad)

JVM: Temurin 17.0.4 Compose version: 1.2.0 Kotlin version: 1.7.10 OS info: image

rock3r commented 1 year ago

And this works on Jetpack Compose, right?

fourlastor commented 1 year ago

Yep, works fine on Jetpack Compose 1.2.0 on Android

fourlastor commented 1 year ago

Just noticed that the scrollbars example works. The issue is only capturing mouse/touchpad events to scroll horizontally

GazimSoliev commented 1 year ago

I have the same problem :(

GazimSoliev commented 1 year ago

LazyRow also doesn't work correctly

igordmn commented 1 year ago

In https://github.com/JetBrains/compose-jb/issues/2690 there was a small workaround described - use Shift with vertical scroll of wheel.

But we still need to support wheel left/right, if the rest of the system supports that.

igordmn commented 1 year ago

Investigation.

Scroll isn't received by Swing (underlying framework):

import java.awt.Dimension
import javax.swing.JFrame
import javax.swing.SwingUtilities

fun main() {
    SwingUtilities.invokeLater {
        val j = JFrame()
        j.addMouseWheelListener {
            println("wheel")
        }
        j.size = Dimension(200, 200)
        j.isVisible = true
    }
}

Doesn't work on JBR 17, JDK 17. But it works in IDEA somehow. We should look at its sources.

m-sasha commented 1 year ago

If vertical scrolling works, surely the events are received, no?

igordmn commented 1 year ago

When we scroll vertically - we receive events. When horizontally - we don't receive.

m-sasha commented 1 year ago

@igordmn I think we're talking about different things.

I think you're talking about physical horizontal scrolling, like a horizontal scroll-wheel?

I'm talking about vertical scroll events causing horizontal scrolling in the UI.

Not sure what the original bug reporter meant.

mbunderline76 commented 1 year ago

i'm wondering when this issue is going to fix

dima-avdeev-jb commented 1 year ago

@mbunderline76

i'm wondering when this issue is going to fix

Based on other issues and priorities, we want to postpone fix of current issue.

tealsnow commented 9 months ago

@mbunderline76

i'm wondering when this issue is going to fix

This is a problem for me when using a trackpad, i.e. scrolling with two fingers left and right. I should not have to hold down shift for compose to receive horizontal scroll events.

NuruNabiyev commented 6 months ago

I did an investigation and still can't receive horizontal scroll events (without pressing shift). I checked out intellij community source code, I even tried jetbrains runtime (21) but the scroll events are still not received! Also tried the --add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED but nothing works...

This is a huge problem for my app as well because it is 2d canvas based. Do you have any updates on this @igordmn? Thanks in advance

PMARZV commented 5 months ago

@igordmn same problem here, users (i include myself here) would expect scrolling without having to shift to work. Is there any workaround so that it works? The expected behaviour should be like the tabs row in intellj idea. Thanks to all the team btw! (its also not working on windows)

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.