scoop:scoop.ui.component:0.1.0
platform/desktop/native/popup/builder.scoop
Selected production source · platform/desktop/native/popup/builder.scoop
1
package scoop.ui.component3
import scoop.graphics.text.FontCollection4
import scoop.ui.*5
import scoop.ui.style.ThemeSource6
import scoop.window.PopupResult8
public class NativeMenuButtonBuilder internal constructor() {9
public var enabled: Boolean = true10
public var variant: ButtonVariant = ButtonVariant.Default11
public var size: ButtonSize = ButtonSize.Default12
public var style: ButtonStyle = buttonStyle()13
public var focus: FocusOptions = FocusOptions()14
public var fonts: FontCollection? = None15
public var theme: ThemeSource? = None16
public var group: GroupPosition? = None17
public var handle: NativePopupHandle? = None18
public var onClosed: (PopupResult) -> Unit = {}19
public var key: ViewKey = ViewKey.Position20
public fun style(configure: ButtonStyleBuilder.() -> Unit) {21
style = style.copy(configure)22
}23
public fun focus(configure: FocusOptionsBuilder.() -> Unit) {24
focus = focus.copy(configure)25
}26
}28
public fun nativeMenuButton(29
text: String,30
menu: NativeMenuContent,31
configure: NativeMenuButtonBuilder.() -> Unit = {}32
): View {33
val builder = NativeMenuButtonBuilder()34
builder.configure()35
return component(36
NativeMenuButtonProps(37
PopupTriggerSpec(38
ButtonContent.Label(LabelProps(LabelText.Plain(text, None))),39
builder.enabled,40
builder.variant,41
builder.size,42
builder.style,43
builder.focus,44
builder.fonts45
),46
menu,47
builder.theme,48
builder.group,49
builder.handle,50
builder.onClosed51
),52
{ current, mount -> NativeMenuButton(current, scope = mount) },53
builder.key54
)55
}57
public class NativeContextMenuBuilder internal constructor() {58
public var enabled: Boolean = true59
public var longPress: LongPressOptions = LongPressOptions()60
public var handle: NativePopupHandle? = None61
public var onClosed: (PopupResult) -> Unit = {}62
public var key: ViewKey = ViewKey.Position63
}65
public fun nativeContextMenu(66
content: View,67
menu: NativeMenuContent,68
configure: NativeContextMenuBuilder.() -> Unit = {}69
): View {70
val builder = NativeContextMenuBuilder()71
builder.configure()72
return component(73
NativeContextMenuProps(74
content,75
menu,76
builder.enabled,77
builder.handle,78
builder.onClosed,79
builder.longPress80
),81
{ current, mount -> NativeContextMenu(current, scope = mount) },82
builder.key83
)84
}