MCPcopy Create free account
hub / github.com/cogentcore/core / InitValueButton

Function InitValueButton

core/value.go:111–123  ·  view source on GitHub ↗

InitValueButton configures the given [Value] to open a dialog representing its value in accordance with the given dialog construction function when clicked. It also sets the tooltip of the widget appropriately. If allowReadOnly is false, the dialog will not be opened if the widget is read only. It a

(v Value, allowReadOnly bool, make func(d *Body), after ...func())

Source from the content-addressed store, hash-verified

109// the dialog will not be opened if the widget is read only. It also takes an optional
110// function to call after the dialog is accepted.
111func InitValueButton(v Value, allowReadOnly bool, make func(d *Body), after ...func()) {
112 wb := v.AsWidget()
113 // windows are never new on mobile
114 if !TheApp.Platform().IsMobile() {
115 wb.SetTooltip(shiftNewWindow)
116 }
117 wb.OnClick(func(e events.Event) {
118 if allowReadOnly || !wb.IsReadOnly() {
119 wb.valueNewWindow = e.HasAnyModifier(key.Shift)
120 openValueDialog(v, make, after...)
121 }
122 })
123}
124
125// openValueDialog opens a new value dialog for the given [Value] using the
126// given function for constructing the dialog and the optional given function

Callers 15

InitMethod · 0.92
InitMethod · 0.92
InitMethod · 0.92
InitMethod · 0.92
InitMethod · 0.92
InitMethod · 0.85
InitMethod · 0.85
InitMethod · 0.85
InitMethod · 0.85
InitMethod · 0.85
InitMethod · 0.85
InitMethod · 0.85

Calls 8

openValueDialogFunction · 0.85
IsMobileMethod · 0.80
SetTooltipMethod · 0.80
AsWidgetMethod · 0.65
PlatformMethod · 0.65
HasAnyModifierMethod · 0.65
OnClickMethod · 0.45
IsReadOnlyMethod · 0.45

Tested by

no test coverage detected