Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll wheel not working on TextField with scrollbars #521

Closed
NiklasMehlhase opened this issue Mar 19, 2021 · 3 comments
Closed

Scroll wheel not working on TextField with scrollbars #521

NiklasMehlhase opened this issue Mar 19, 2021 · 3 comments
Assignees
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related

Comments

@NiklasMehlhase
Copy link

NiklasMehlhase commented Mar 19, 2021

What I am trying to do:

  • Adding scrollbars to a textfield

What works:

  • Scrolling by dragging the scrollbars
  • Using a Text instead of a TextField
  • Scrolling with the scroll wheel on a TextField without scrollbars

What does not work:

  • Scrolling with the scroll wheel when using a TextField

What I tried:

  • Using BasicTextField instead of TextField
  • Wrapping the TextField in a Column and making the Column scrollable
  • Tried versions 0.4.0-build174 and 0.3.2
  • Tried mouseScrollFilter on TextField (onMouseScroll is never getting called)

My code:

import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.TextField
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.IntSize

fun main() = Window(title = "Scrollbars", size = IntSize(280, 400)) {
    MaterialTheme {
        Box(
            modifier = Modifier.fillMaxSize()
        ) {
            val verticalScrollState = rememberScrollState(0)
            val horizontalScrollState = rememberScrollState(0)

            TextField(
                ("This is a test. ".repeat(5) + "\n").repeat(30),
                onValueChange = {},
                modifier = Modifier
                    .verticalScroll(verticalScrollState)
                    .horizontalScroll(horizontalScrollState)
            )
            VerticalScrollbar(
                modifier = Modifier
                    .fillMaxHeight()
                    .align(Alignment.CenterEnd),
                adapter = rememberScrollbarAdapter(verticalScrollState)
            )
            HorizontalScrollbar(
                modifier = Modifier
                    .fillMaxWidth()
                    .align(Alignment.BottomCenter),
                adapter = rememberScrollbarAdapter(horizontalScrollState)
            )
        }
    }
}
@igordmn igordmn added the input Touch, mouse, keyboard input related label Mar 22, 2021
@igordmn igordmn self-assigned this Mar 22, 2021
@Inego
Copy link

Inego commented Mar 23, 2021

Relates to #26?

@akurasov akurasov added desktop bug Something isn't working labels Jul 19, 2021
@NiklasMehlhase
Copy link
Author

The issue is no longer present with version 1.0.1 👍

MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
@okushnikov
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working desktop input Touch, mouse, keyboard input related
Projects
None yet
Development

No branches or pull requests

5 participants