diff --git a/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt b/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt index bd32dd1..0d52c0f 100644 --- a/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt +++ b/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt @@ -539,6 +539,7 @@ internal fun PdfPageComposable( isActivePage: Boolean = true, isBubbleZoomModeActive: Boolean = false, isStylusOnlyMode: Boolean = false, + stylusButtonHovering: Boolean = false, isAutoScrollPlaying: Boolean = false, isHighlighterSnapEnabled: Boolean = false, userHighlights: List = emptyList(), @@ -3335,7 +3336,7 @@ internal fun PdfPageComposable( "Page $pageIndex | Type: ${down.type} | isPrimary: ${buttons.isPrimaryPressed} | isSecondary: ${buttons.isSecondaryPressed} | isTertiary: ${buttons.isTertiaryPressed} | buttonsString: $buttons" ) - val isEraserOverride = down.type == PointerType.Eraser || (down.type == PointerType.Stylus && currentEvent.buttons.isSecondaryPressed) + val isEraserOverride = down.type == PointerType.Eraser || (down.type == PointerType.Stylus && (currentEvent.buttons.isSecondaryPressed || currentEvent.buttons.isPrimaryPressed || stylusButtonHovering)) isStylusEraserOverride = isEraserOverride val dragPointerId = down.id diff --git a/app/src/main/java/com/aryan/reader/pdf/PdfVerticalReader.kt b/app/src/main/java/com/aryan/reader/pdf/PdfVerticalReader.kt index 57557a5..4cc6a03 100644 --- a/app/src/main/java/com/aryan/reader/pdf/PdfVerticalReader.kt +++ b/app/src/main/java/com/aryan/reader/pdf/PdfVerticalReader.kt @@ -242,6 +242,7 @@ internal fun PdfVerticalReader( autoScrollSpeed: Float = 1.0f, onInteractionListener: () -> Unit = {}, isStylusOnlyMode: Boolean = false, + stylusButtonHovering: Boolean = false, isHighlighterSnapEnabled: Boolean = false, userHighlights: List = emptyList(), onHighlightAdd: (Int, Pair, String, PdfHighlightColor) -> Unit = { _,_,_,_ -> }, @@ -994,7 +995,7 @@ internal fun PdfVerticalReader( ) val isEraserOverride = down.type == PointerType.Eraser || - (down.type == PointerType.Stylus && currentEvent.buttons.isSecondaryPressed) + (down.type == PointerType.Stylus && (currentEvent.buttons.isSecondaryPressed || currentEvent.buttons.isPrimaryPressed || stylusButtonHovering)) isStylusEraserOverride = isEraserOverride fun getPageAndPoint(screenOffset: Offset): Pair? { @@ -1730,6 +1731,7 @@ internal fun PdfVerticalReader( selectedTool = selectedTool, richTextController = richTextController, isStylusOnlyMode = isStylusOnlyMode, + stylusButtonHovering = stylusButtonHovering, isAutoScrollPlaying = isAutoScrollPlaying, textBoxes = textBoxes.filter { it.pageIndex == page.index }, selectedTextBoxId = selectedTextBoxId, diff --git a/app/src/main/java/com/aryan/reader/pdf/PdfViewerScreen.kt b/app/src/main/java/com/aryan/reader/pdf/PdfViewerScreen.kt index 28f1688..5427254 100644 --- a/app/src/main/java/com/aryan/reader/pdf/PdfViewerScreen.kt +++ b/app/src/main/java/com/aryan/reader/pdf/PdfViewerScreen.kt @@ -3491,6 +3491,7 @@ fun PdfViewerScreen( Scaffold( contentWindowInsets = WindowInsets(0, 0, 0, 0), ) { _ -> + var stylusButtonHovering by remember { mutableStateOf(false) } BoxWithConstraints( modifier = Modifier .fillMaxSize() @@ -3508,6 +3509,9 @@ fun PdfViewerScreen( "tertiary=${buttons.isTertiaryPressed}, back=${buttons.isBackPressed}, " + "forward=${buttons.isForwardPressed}" ) + if (!change.pressed) { + stylusButtonHovering = buttons.isPrimaryPressed || buttons.isSecondaryPressed + } } } } @@ -3914,6 +3918,7 @@ fun PdfViewerScreen( }, richTextController = richTextController, isStylusOnlyMode = isStylusOnlyMode, + stylusButtonHovering = stylusButtonHovering, isAutoScrollPlaying = isAutoScrollPlaying, isHighlighterSnapEnabled = isHighlighterSnapEnabled, isEditMode = isDrawingActive, @@ -4321,6 +4326,7 @@ fun PdfViewerScreen( selectedTool = selectedTool, richTextController = richTextController, isStylusOnlyMode = isStylusOnlyMode, + stylusButtonHovering = stylusButtonHovering, isEditMode = isDrawingActive, textBoxes = textBoxes, selectedTextBoxId = selectedTextBoxId,