Unverified Commit 5e5ea520 authored by dima.avdeev's avatar dima.avdeev Committed by GitHub

fix iOS TextField Context menu blink bug (#735)

Issue: https://github.com/JetBrains/compose-multiplatform/issues/3276
parent 20bc1d2f
...@@ -58,17 +58,25 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol, ...@@ -58,17 +58,25 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
fun showTextMenu(targetRect: Rect, textActions: TextActions) { fun showTextMenu(targetRect: Rect, textActions: TextActions) {
_currentTextMenuActions = textActions _currentTextMenuActions = textActions
val menu: UIMenuController = UIMenuController.sharedMenuController() val menu: UIMenuController = UIMenuController.sharedMenuController()
if (menu.isMenuVisible()) {
menu.hideMenu()
}
val cgRect = CGRectMake( val cgRect = CGRectMake(
x = targetRect.left.toDouble(), x = targetRect.left.toDouble(),
y = targetRect.top.toDouble(), y = targetRect.top.toDouble(),
width = targetRect.width.toDouble(), width = targetRect.width.toDouble(),
height = targetRect.height.toDouble() height = targetRect.height.toDouble()
) )
val isTargetVisible = CGRectIntersectsRect(bounds, cgRect)
if (isTargetVisible) {
if (menu.isMenuVisible()) {
menu.setTargetRect(cgRect, this)
} else {
menu.showMenuFromView(this, cgRect) menu.showMenuFromView(this, cgRect)
} }
} else {
if (menu.isMenuVisible()) {
menu.hideMenu()
}
}
}
fun hideTextMenu() { fun hideTextMenu() {
_currentTextMenuActions = null _currentTextMenuActions = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment