holy crap click handling works too
This commit was merged in pull request #5.
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"git.vezzani.net/ben/games/common/elements/v1"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/blocks"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/buttons"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/mouse"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/stacks"
|
||||
"git.vezzani.net/ben/games/common/sprites/v1"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
@@ -20,7 +22,12 @@ var root = stacks.New(
|
||||
stacks.New(
|
||||
stacks.BlockOpt(blocks.Name("left")),
|
||||
stacks.Children(
|
||||
blocks.New(blocks.BackgroundColor(colornames.Green)),
|
||||
buttons.New(
|
||||
buttons.BlockOpt(blocks.BackgroundColor(colornames.Green)),
|
||||
buttons.OnClick(func(ms mouse.State) {
|
||||
println("green")
|
||||
}),
|
||||
),
|
||||
blocks.New(blocks.BackgroundColor(colornames.Yellow)),
|
||||
)),
|
||||
stacks.New(
|
||||
@@ -38,15 +45,14 @@ func newEditor() *editor {
|
||||
}
|
||||
|
||||
type editor struct {
|
||||
root elements.Element
|
||||
bounds elements.Bounds
|
||||
root elements.Element
|
||||
bounds elements.Bounds
|
||||
handleMouse func() bool
|
||||
}
|
||||
|
||||
//var handleClick = mouse.ClickHandler(root)
|
||||
|
||||
func (e *editor) Update() error {
|
||||
sprites.Update()
|
||||
//handleClick()
|
||||
e.handleMouse()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,6 +68,7 @@ func (e *editor) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHei
|
||||
Height: float64(outsideHeight),
|
||||
}
|
||||
e.root = root(e.bounds)
|
||||
e.handleMouse = mouse.Handler(e.root)
|
||||
}
|
||||
|
||||
return outsideWidth, outsideHeight
|
||||
|
||||
Reference in New Issue
Block a user