fun onMouseDown()

in sample/src/main/kotlin/org/jetbrains/desktop/sample/linux/SkikoSampleLinux.kt [708:765]


    fun onMouseDown(
        event: Event.MouseDown,
        clipboardHandler: ClipboardHandler,
        modifiers: Set<KeyModifiers>,
        editorState: EditorState,
    ): EventHandlerResult {
        return when (event.button) {
            MouseButton.LEFT -> when (modifiers.shortcutModifiers()) {
                setOf(KeyModifiers.Alt) -> {
                    val skikoTextLine = dragIconTextLineCreator.makeTextLine(EXAMPLE_FILES.joinToString("\n"), 10f)
                    val dragIconParams = DragIconParams(
                        renderingMode = RenderingMode.Auto,
                        size = LogicalSize(width = skikoTextLine.width, height = skikoTextLine.height),
                    )
                    val content = DataTransferContentType.UriList(EXAMPLE_FILES)
                    val startDragAndDropParams = StartDragAndDropParams(
                        mimeTypes = content.mimeTypes(),
                        actions = setOf(DragAndDropAction.Copy),
                        dragIconParams,
                    )
                    clipboardHandler.startDrag(content, startDragAndDropParams) { canvas, scale ->
                        val skikoTextLine = dragIconTextLineCreator.makeTextLine(EXAMPLE_FILES.joinToString("\n"), (10.0 * scale).toFloat())
                        Paint().use { paint ->
                            paint.color = Color.BLACK
                            canvas.drawTextLine(skikoTextLine, x = skikoTextLine.leading, y = -skikoTextLine.ascent, paint)
                        }
                    }
                    EventHandlerResult.Stop
                }

                else -> {
                    editorState.getCurrentSelection()?.let {
                        val skikoTextLine = dragIconTextLineCreator.makeTextLine(it, 30f)
                        val dragIconParams = DragIconParams(
                            renderingMode = RenderingMode.Auto,
                            size = LogicalSize(width = skikoTextLine.width, height = skikoTextLine.height),
                        )
                        val content = DataTransferContentType.Text(it)
                        val startDragAndDropParams = StartDragAndDropParams(
                            mimeTypes = content.mimeTypes(),
                            actions = setOf(DragAndDropAction.Copy, DragAndDropAction.Move),
                            dragIconParams,
                        )
                        clipboardHandler.startDrag(content, startDragAndDropParams) { canvas, scale ->
                            val skikoTextLine = dragIconTextLineCreator.makeTextLine(it, (30.0 * scale).toFloat())
                            Paint().use { paint ->
                                paint.color = Color.BLACK
                                canvas.drawTextLine(skikoTextLine, x = skikoTextLine.leading, y = -skikoTextLine.ascent, paint)
                            }
                        }
                        EventHandlerResult.Stop
                    } ?: EventHandlerResult.Continue
                }
            }

            else -> EventHandlerResult.Continue
        }
    }