33 lines
581 B
Go
33 lines
581 B
Go
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)
|
|
}
|
|
}
|