I would like to have a scrollable element for hori...
# compose-desktop
s
I would like to have a scrollable element for horizontal scoll. I tried the following two code as example and both didn't work. Is there another way to get the scrollable element?
Copy code
fun main() = Window {
    val stateVertical = rememberScrollState(0F)
    Row(modifier = Modifier.width(400.dp)
        .horizontalScroll(stateVertical)) {
        listOf(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17).forEach{
            val text = "Hello, Desktop! $it"
            Button(onClick = {
            }) {
                Text(text)
            }
        }
    }
}
Copy code
fun main() = Window {
    ScrollableRow (modifier = Modifier.width(400.dp)){
        listOf(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17).forEach{
            val text = "Hello, Desktop! $it"
            Button(onClick = {
            }) {
                Text(text)
            }
        }
    }
}
a
First you could replace your list by a range,
(1..17).forEach { ... }
k
Start with the sample at https://github.com/JetBrains/compose-jb/tree/master/tutorials/Desktop_Components and work your way towards your specific content
s
Thank your for the link. I forgot the ScrollBar. I thought that it’s possible to scroll horizontal with the mouse.