fun onMouseDown()

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


    fun onMouseDown(
        event: Event.MouseDown,
        window: Window,
        editorState: EditorState,
        modifiers: Set<KeyModifiers>,
        clipboardHandler: ClipboardHandler,
        xdgDesktopSettings: XdgDesktopSettings,
    ): EventHandlerResult {
        if (customBorders?.onMouseDown(event, window) == EventHandlerResult.Stop) {
            return EventHandlerResult.Stop
        }
        if (customTitlebar?.onMouseDown(event) == EventHandlerResult.Stop) {
            return EventHandlerResult.Stop
        }
        if (contentArea.onMouseDown(event, clipboardHandler, modifiers, editorState) == EventHandlerResult.Stop) {
            return EventHandlerResult.Stop
        }

        return if (event.button == MouseButton.MIDDLE) {
            when (modifiers.shortcutModifiers()) {
                setOf(KeyModifiers.Control) -> {
                    editorState.getCurrentSelection()?.let { selection ->
                        clipboardHandler.copyToPrimarySelection(DataTransferContentType.Text(selection))
                        EventHandlerResult.Stop
                    } ?: EventHandlerResult.Continue
                }

                setOf(KeyModifiers.Shift) -> {
                    if (xdgDesktopSettings.middleClickPaste) {
                        clipboardHandler.pasteFromPrimarySelection(listOf(PNG_MIME_TYPE, URI_LIST_MIME_TYPE, TEXT_MIME_TYPE))
                        EventHandlerResult.Stop
                    } else {
                        EventHandlerResult.Continue
                    }
                }

                emptySet<KeyModifiers>() -> {
                    window.startResize(WindowResizeEdge.Top)
                    EventHandlerResult.Stop
                }

                else -> EventHandlerResult.Continue
            }
        } else {
            EventHandlerResult.Continue
        }
    }