scoop:scoop.ui.component:0.1.0
platform/desktop/native/popup/handle.scoop
Selected production source · platform/desktop/native/popup/handle.scoop
1
package scoop.ui.component3
import scoop.ui.state4
import scoop.window.LogicalPosition6
/** One mounted trigger, with explicit requests instead of a persistent open value. */7
public class NativePopupHandle public constructor() {8
private var owner: NativePopupPresentation? = None9
private val pending = state(false)11
public val isPending: Boolean get() = pending.value12
public fun requestOpen(): Boolean = owner?.open(None) ?: false13
public fun cancel() {14
owner?.cancel()15
}17
internal fun bind(value: NativePopupPresentation) {18
when (owner) {19
case Some(val current) -> requireComponent(20
current === value,21
"native popup handle is already mounted"22
)23
case None -> {}24
}25
owner = Some(value)26
pending.value = value.isPending27
}28
internal fun unbind(value: NativePopupPresentation) {29
when (owner) {30
case Some(val current) -> if (current === value) {31
owner = None32
pending.value = false33
}34
case None -> {}35
}36
}37
internal fun changed(value: Boolean) {38
pending.value = value39
}40
}