This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
widgets/src/iosMain/kotlin/dev/icerock/moko/widgets/core Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ actual class ButtonWithIconViewFactory actual constructor(
100100
101101 button.setEventHandler(
102102 controlEvent = UIControlEventTouchUpInside ,
103- action = widget.onTap
103+ action = { widget.onTap }
104104 )
105105
106106 val contentAttribute: UISemanticContentAttribute
Original file line number Diff line number Diff line change @@ -20,8 +20,13 @@ import platform.objc.OBJC_ASSOCIATION_RETAIN
2020import platform.objc.objc_setAssociatedObject
2121import kotlin.native.ref.WeakReference
2222
23- fun UIControl.setEventHandler (controlEvent : UIControlEvents , action : () -> Unit ) {
24- val target = LambdaTarget (action)
23+ fun <V : UIControl > V.setEventHandler (controlEvent : UIControlEvents , action : (V ) -> Unit ) {
24+ val weakReference: WeakReference <V > = WeakReference (this )
25+ val target = LambdaTarget {
26+ val strongRef: V = weakReference.get() ? : return @LambdaTarget
27+
28+ action(strongRef)
29+ }
2530
2631 addTarget(
2732 target = target,
You can’t perform that action at this time.
0 commit comments