Update popup.go

This commit is contained in:
Alexei Anoshenko 2026-08-10 16:00:40 +03:00
parent b18c632a44
commit 42067e1791
1 changed files with 25 additions and 0 deletions

View File

@ -294,6 +294,8 @@ type PopupButton struct {
// OnClick is the handler function that gets called when the button is pressed // OnClick is the handler function that gets called when the button is pressed
OnClick func(Popup) OnClick func(Popup)
Binding string
} }
type popupButton struct { type popupButton struct {
@ -602,6 +604,29 @@ func (popup *popupData) Get(tag PropertyName) any {
} }
} }
return nil 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) return popup.getRaw(tag)