holy crap click handling works too
This commit was merged in pull request #5.
This commit is contained in:
32
common/elements/v1/buttons/options.go
Normal file
32
common/elements/v1/buttons/options.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user