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())
| 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. |
| 111 | func 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 |
no test coverage detected