holy crap click handling works too

This commit was merged in pull request #5.
This commit is contained in:
2025-08-29 22:58:06 -04:00
parent 4829fbb5c7
commit 430259475b
9 changed files with 173 additions and 119 deletions

View File

@@ -0,0 +1,32 @@
package buttons
import (
"git.vezzani.net/ben/games/common/elements/v1/blocks"
"git.vezzani.net/ben/games/common/elements/v1/mouse"
)
type Option func(button *Button)
func OnClick(f func(ms mouse.State)) Option {
return func(button *Button) {
button.onClick = f
}
}
func OnMouseDown(f func(ms mouse.State)) Option {
return func(button *Button) {
button.onMouseDown = f
}
}
func OnMouseUp(f func(ms mouse.State)) Option {
return func(button *Button) {
button.onMouseUp = f
}
}
func BlockOpt(o blocks.Option) Option {
return func(s *Button) {
o(&s.Block)
}
}