From 0d87db09874b51ac0d05607d313ff5d466095ee1 Mon Sep 17 00:00:00 2001 From: davide magli Date: Tue, 26 Sep 2023 15:41:47 +0200 Subject: [PATCH] Added logic that manages the scroll wheel click on the tabs --- core/src/main/kotlin/org/jetbrains/jewel/Tabs.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/org/jetbrains/jewel/Tabs.kt b/core/src/main/kotlin/org/jetbrains/jewel/Tabs.kt index 5261e96751..f9ed073146 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/Tabs.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/Tabs.kt @@ -34,6 +34,9 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.graphics.drawscope.ContentDrawScope +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.isTertiary +import androidx.compose.ui.input.pointer.onPointerEvent import androidx.compose.ui.res.painterResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp @@ -108,7 +111,10 @@ internal fun TabImpl( cap = StrokeCap.Round, ) } - .padding(tabStyle.metrics.tabPadding), + .padding(tabStyle.metrics.tabPadding) + .onPointerEvent(PointerEventType.Release) { + if (it.button.isTertiary) tabData.onClose() + }, horizontalArrangement = Arrangement.spacedBy(tabStyle.metrics.closeContentGap), verticalAlignment = Alignment.CenterVertically, ) {