Skip to content

Commit

Permalink
fix: shortcut also triggers when Popup is available
Browse files Browse the repository at this point in the history
  • Loading branch information
hstyi committed Feb 15, 2025
1 parent 5fdfe98 commit 082c9e9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/kotlin/app/termora/keymap/KeymapManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import com.formdev.flatlaf.util.SystemInfo
import org.apache.commons.lang3.StringUtils
import org.jdesktop.swingx.action.ActionManager
import org.slf4j.LoggerFactory
import java.awt.Container
import java.awt.KeyEventDispatcher
import java.awt.KeyboardFocusManager
import java.awt.event.KeyEvent
import javax.swing.JComponent
import javax.swing.JDialog
import javax.swing.KeyStroke
import javax.swing.SwingUtilities
import javax.swing.*

class KeymapManager private constructor() : Disposable {

Expand Down Expand Up @@ -127,6 +125,16 @@ class KeymapManager private constructor() : Disposable {
return false
}

// 如果当前有 Popup ,那么不派发事件
val c = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner
val popups: List<JPopupMenu> = SwingUtils.getDescendantsOfType(
JPopupMenu::class.java,
c as Container, true
)
if (popups.isNotEmpty()) {
return false
}


val evt = AnActionEvent(e.source, StringUtils.EMPTY, e)
for (actionId in actionIds) {
Expand Down

0 comments on commit 082c9e9

Please sign in to comment.