Created
June 22, 2016 15:29
-
-
Save duckbrain/fea63f8731bfef36440620448a2aa6b8 to your computer and use it in GitHub Desktop.
Example of callbacks for andlabs/ui.Area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/andlabs/ui" | |
type AreaCallbacks struct { | |
onDraw func(a *ui.Area, dp *ui.AreaDrawParams) | |
onMouseEvent func(a *ui.Area, me *ui.AreaMouseEvent) | |
onMouseCrossed func(a *ui.Area, left bool) | |
onDragBroken func(a *ui.Area) | |
onKeyEvent func(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) | |
} | |
func (c *AreaCallbacks) OnDraw(onDraw func(a *ui.Area, dp *ui.AreaDrawParams)) { | |
c.onDraw = onDraw | |
} | |
func (c *AreaCallbacks) OnMouseEvent(onMouseEvent func(a *ui.Area, me *ui.AreaMouseEvent)) { | |
c.onMouseEvent = onMouseEvent | |
} | |
func (c *AreaCallbacks) OnMouseCrossed(onMouseCrossed func(a *ui.Area, left bool)) { | |
c.onMouseCrossed = onMouseCrossed | |
} | |
func (c *AreaCallbacks) OnDragBroken(onDragBroken func(a *ui.Area)) { | |
c.onDragBroken = onDragBroken | |
} | |
func (c *AreaCallbacks) OnKeyEvent(onKeyEvent func(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool)) { | |
c.onKeyEvent = onKeyEvent | |
} | |
func (c *AreaCallbacks) Draw(a *ui.Area, dp *ui.AreaDrawParams) { | |
c.onDraw(a, dp) | |
} | |
func (c *AreaCallbacks) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) { | |
c.onMouseEvent(a, me) | |
} | |
func (c *AreaCallbacks) MouseCrossed(a *ui.Area, left bool) { | |
c.onMouseCrossed(a, left) | |
} | |
func (c *AreaCallbacks) DragBroken(a *ui.Area) { | |
c.onDragBroken(a) | |
} | |
func (c *AreaCallbacks) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) { | |
return c.onKeyEvent(a, ke) | |
} | |
func main() { | |
var callbacks ui.AreaHandler | |
callbacks = &AreaCallbacks{} | |
_ = callbacks | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment