אליהו הדס
08/10/2025, 5:41 PMseb
08/10/2025, 5:55 PMseb
08/10/2025, 5:55 PMאליהו הדס
08/10/2025, 5:56 PMseb
08/10/2025, 5:57 PMאליהו הדס
08/10/2025, 5:57 PMseb
08/10/2025, 5:58 PMאליהו הדס
08/10/2025, 5:59 PMseb
08/10/2025, 5:59 PMseb
08/10/2025, 5:59 PMאליהו הדס
08/10/2025, 6:00 PMאליהו הדס
08/10/2025, 6:22 PM@OptIn(ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class)
fun Modifier.verticalScrollToHorizontal(): Modifier = this.onPointerEvent(PointerEventType.Scroll) { event ->
val change = event.changes.firstOrNull()
if (change != null) {
val scrollDelta = change.scrollDelta
// If we detect vertical scroll (y != 0) and no horizontal scroll (x == 0)
if (scrollDelta.y != 0f && scrollDelta.x == 0f) {
try {
// Use Robot to simulate Shift + Wheel
val robot = Robot()
// Press Shift
robot.keyPress(KeyEvent.VK_SHIFT)
// Wait a bit for the key to be properly registered
Thread.sleep(10)
// Simulate mouse scroll
// Note: scrollDelta.y is negative for scroll up, positive for scroll down
// MouseWheelEvent uses the inverse convention
val scrollAmount = if (scrollDelta.y > 0) 1 else -1
robot.mouseWheel(scrollAmount)
// Release Shift
Thread.sleep(10)
robot.keyRelease(KeyEvent.VK_SHIFT)
// Consume the original event to avoid double scroll
change.consume()
} catch (e: Exception) {
// In case of error (for example on certain platforms where Robot is not available)
e.printStackTrace()
}
}
}
}
seb
08/10/2025, 6:30 PMseb
08/10/2025, 6:31 PMseb
08/10/2025, 6:31 PMאליהו הדס
08/10/2025, 6:32 PMאליהו הדס
08/10/2025, 6:32 PMseb
08/10/2025, 6:33 PM