ayodele
12/30/2022, 12:23 PMScrollPanel with a SimpleMutableListModelNick
12/30/2022, 2:14 PMScrollPanel is the right way to make scrollable regions. Did you include nativeScrollPanelBehavior() in you modules when launching the app, and install a theme? ScrollPanels need this behavior to perform scrolling.Nick
12/30/2022, 2:24 PMclass ListDemo(
display : Display,
themeManager: ThemeManager,
theme : DynamicTheme,
…
): Application {
init {
themeManager.selected = theme
val list = List(
model,
selectionModel = MultiSelectionModel(),
itemVisualizer = …,
fitContent = setOf(Height)
).apply {
…
cellAlignment = fill
}
display += ScrollPanel(list).apply {
size = Size(400, 200)
}
}
}
override fun shutdown() {}
companion object {
private val appModules = listOf(
nativeScrollPanelBehavior(),
…
)
operator fun invoke() = application(modules = appModules) {
ListDemo(instance(), instance(), instance(), …)
}
}
}Nick
12/30/2022, 2:36 PMList in the ScrollPanel? You’ll also need a Behavior for it (see sample above). I’m not at my computer, so the code above might have some minor issues, but this is how you’d make a List scrollable.
Note that ScrollPanel can only have a single item in them. So you’d wrap your Views in a Collection or something else if you wanted to make them scroll. You can also make the ScrollPanel fill the display if it’s your topmost View.
You can also see how ScrollPanels are used by checking out the Todo tutorial code.ayodele
12/30/2022, 2:48 PMayodele
12/30/2022, 2:49 PMNick
12/30/2022, 3:04 PMayodele
12/30/2022, 4:28 PMview{} but I'm still getting white backgroundayodele
12/30/2022, 4:29 PMayodele
12/30/2022, 4:35 PMrenderNick
12/30/2022, 4:39 PMrender = {
rect(bounds.atOrigin(), fill = backgroundColor!!.paint)
}Nick
12/30/2022, 4:39 PMayodele
12/30/2022, 4:40 PMayodele
12/30/2022, 4:41 PMayodele
12/30/2022, 4:43 PMPointNick
12/30/2022, 4:49 PMLayout. You can place one on the Display just like Containers.Nick
12/30/2022, 4:49 PMayodele
01/07/2023, 2:22 PMNick
01/07/2023, 2:44 PMcontentWidthConstraints = { it eq parent.width - panel.verticalScrollBarWidth }
contentHeightConstraints = { it eq parent.height - panel.horizontalScrollBarHeight }
You can see that these properties default to sizing the panel’s content to its ideal width and height.ayodele
01/07/2023, 4:15 PM