diff --git a/skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt b/skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt index 360eb7dc8..819624d61 100644 --- a/skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt +++ b/skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt @@ -58,16 +58,24 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol, fun showTextMenu(targetRect: Rect, textActions: TextActions) { _currentTextMenuActions = textActions val menu: UIMenuController = UIMenuController.sharedMenuController() - if (menu.isMenuVisible()) { - menu.hideMenu() - } val cgRect = CGRectMake( x = targetRect.left.toDouble(), y = targetRect.top.toDouble(), width = targetRect.width.toDouble(), height = targetRect.height.toDouble() ) - menu.showMenuFromView(this, cgRect) + val isTargetVisible = CGRectIntersectsRect(bounds, cgRect) + if (isTargetVisible) { + if (menu.isMenuVisible()) { + menu.setTargetRect(cgRect, this) + } else { + menu.showMenuFromView(this, cgRect) + } + } else { + if (menu.isMenuVisible()) { + menu.hideMenu() + } + } } fun hideTextMenu() {