[英]Compose for Desktop LazyRow/LazyColumn not scrolling with mouse click
For some reason LazyColumn
s do not scroll with a mouse click and move gesture.由于某种原因
LazyColumn
不会通过鼠标单击和移动手势滚动。 It only works with the mouse wheel so far.到目前为止,它仅适用于鼠标滚轮。 For
LazyRow
s it is also not possible to scroll with the mouse wheel.对于
LazyRow
,也无法使用鼠标滚轮滚动。 It seems that lazy row is useless for Compose for desktop.似乎惰性行对于 Compose for desktop 没用。
Are there any possiblities to enable a click and move gesture on LazyRow
and LazyColum
.是否可以在
LazyRow
和LazyColum
上启用单击和移动手势。 And if not is it at least possible to enable to scroll through a LazyRow
with the mouse wheel?如果不是,至少可以使用鼠标滚轮滚动
LazyRow
吗?
I used this minimal reproducible example to test the scrolling我使用这个最小的可重现示例来测试滚动
@Composable
@Preview
fun App() {
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
LazyRow(modifier = Modifier.fillMaxSize()) {
repeat(100) {
item {
Text("Test Test Test Test $it ")
}
}
}
}
}
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}
This is the intended behavior.这是预期的行为。
All scrollable components (including LazyColumn
) work (for now) only with mouse wheel scroll events on the desktop.所有可滚动组件(包括
LazyColumn
)(目前)仅在桌面上使用鼠标滚轮滚动事件时工作。
The scrollable components should not respond to mouse drag/move events.可滚动组件不应响应鼠标拖动/移动事件。
Here's a basic example of how you can add drag support to your components:这是一个基本示例,说明如何向组件添加拖动支持:
val scrollState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
LazyRow(
state = scrollState,
modifier = Modifier
.draggable(
orientation = Orientation.Horizontal,
state = rememberDraggableState { delta ->
coroutineScope.launch {
scrollState.scrollBy(-delta)
}
},
)
) {
items(100) {
Text("Test Test Test Test $it")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.