mirror of https://github.com/anoshenko/rui.git
Update popup.go
This commit is contained in:
parent
b18c632a44
commit
42067e1791
25
popup.go
25
popup.go
|
|
@ -294,6 +294,8 @@ type PopupButton struct {
|
|||
|
||||
// OnClick is the handler function that gets called when the button is pressed
|
||||
OnClick func(Popup)
|
||||
|
||||
Binding string
|
||||
}
|
||||
|
||||
type popupButton struct {
|
||||
|
|
@ -602,6 +604,29 @@ func (popup *popupData) Get(tag PropertyName) any {
|
|||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
case Buttons:
|
||||
if value := popup.getRaw(DismissEvent); value != nil {
|
||||
if buttons, ok := value.([]popupButton); ok {
|
||||
result := make([]PopupButton, 0, len(buttons))
|
||||
for _, button := range buttons {
|
||||
btn := PopupButton{
|
||||
Title: button.title,
|
||||
Type: button.buttonType,
|
||||
}
|
||||
switch listener := button.onClick.rawListener().(type) {
|
||||
case string:
|
||||
btn.Binding = listener
|
||||
|
||||
case func(Popup):
|
||||
btn.OnClick = listener
|
||||
}
|
||||
result = append(result, btn)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return popup.getRaw(tag)
|
||||
|
|
|
|||
Loading…
Reference in New Issue