04/17/2023, 1:36 PM
I would like to convert my Swing application to Compose. Therefore, I need multi-select support for a LazyColumn. I have found some open source implementations, but none of them support multi-select with ctrl/shift key for selecting ranges of elements. Is there anyone who has already implemented something like this?


04/17/2023, 1:55 PM
This looks similar to, even if not a table No specific solutions in here, just thought it was worth mentioning


04/17/2023, 9:49 PM
I added a PointerEvent to each item:
.onPointerEvent(PointerEventType.Press) { clicked(item, it) }
In "clicked" I check which mouse button was pressed and which keys (pointerEvent.keyboardModifiers.isCtrlPressed and pointerEvent.keyboardModifiers.isShiftPressed). This way I fill a mutableStateListOf with all "selected" items. I think the behavior is now like in my old Swing list (not easy to get all cases right with ctrl/shift 🤔!). However, my items are wrapped in a ContextMenuArea to show a context menu for each item. In Swing, right-clicking to open the context menu also selects an item (but only if it's not already selected, then ALL selected items remain selected). My problem now is: When the context menu opens, the PointerEvent.Press is fired so I can check if the clicked item needs to be selected. However, if I right-click another item while the context menu is still open(!), then no PointerEvent.Press is fired?! Any ideas how to get PointerEvents for right-clicking while the context menu is open? By the way: The documentation for the "onPointerEvent"-modifier says: "_Note that this function is experimental, and can be replaced in the future by high-level functions"_ Is it known if there is a real plan to replace these features?
Dima Avdeev answered a question from Hondogo Paul about pointer drag events. The coding works in my case as well:
modifier = Modifier
             .pointerInput(Unit) {
                awaitPointerEventScope {
                    while (true) {
                        val pointerEvent = awaitPointerEvent()
                        val isMouseDown = pointerEvent.buttons.areAnyPressed
                        if(isMouseDown) {
                            println("click in pointer input modifier")
                            clicked(solution, pointerEvent)
    .onPointerEvent(PointerEventType.Press) { println("click in onPointerEvent") }
The text "click in pointer input modifier" is also printed when I right-click while a contextMenu is displayed. However, the text "click in onPointerEvent" is not displayed, so that pointer event isn't fired when a contextMenu is open and then another item is clicked. So the solution for me is to use the ".pointerInput(Unit)" modifier to check for clicks while the contextMenu is open.