From 0b12843b67da8abe38e8bfdc2691517c4cdfe9e1 Mon Sep 17 00:00:00 2001 From: Henry Wylde Date: Tue, 30 Jul 2024 14:12:11 +1200 Subject: [PATCH] RUBY-32242 IJPL-159537 add support for changing the cursor to a hand when hovering over declarative inlay hints GitOrigin-RevId: 079c123a92081524a6f5ef166057c8577e6a2175 --- .../DeclarativeInlayHintsMouseMotionListener.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/declarative/impl/DeclarativeInlayHintsMouseMotionListener.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/declarative/impl/DeclarativeInlayHintsMouseMotionListener.kt index f15d7a77e911..2e3b0abd2354 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/declarative/impl/DeclarativeInlayHintsMouseMotionListener.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/declarative/impl/DeclarativeInlayHintsMouseMotionListener.kt @@ -6,7 +6,9 @@ import com.intellij.openapi.editor.Inlay import com.intellij.openapi.editor.event.EditorMouseEvent import com.intellij.openapi.editor.event.EditorMouseEventArea import com.intellij.openapi.editor.event.EditorMouseMotionListener +import com.intellij.openapi.editor.ex.EditorEx import com.intellij.ui.LightweightHint +import java.awt.Cursor import java.awt.Point import java.awt.event.MouseEvent import java.lang.ref.WeakReference @@ -43,11 +45,16 @@ class DeclarativeInlayHintsMouseMotionListener : EditorMouseMotionListener { } } - val newEntries = mouseArea?.entries - if (newEntries != null) { - for (entry in newEntries) { - entry.isHoveredWithCtrl = ctrlDown - } + val newEntries = mouseArea?.entries ?: emptyList() + for (entry in newEntries) { + entry.isHoveredWithCtrl = ctrlDown + } + + if (ctrlDown && newEntries.isNotEmpty()) { + (e.editor as? EditorEx)?.setCustomCursor(DeclarativeInlayHintsMouseMotionListener::class.java, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)) + } + else { + (e.editor as? EditorEx)?.setCustomCursor(DeclarativeInlayHintsMouseMotionListener::class.java, null) } inlayUnderCursor?.get()?.update()