redstarcoder / draw2dui

draw2dui is a golang package for drawing user interfaces using draw2d and OpenGL.
BSD 2-Clause "Simplified" License
2 stars 0 forks source link

Add callbacks to widget interface #6

Open redstarcoder opened 7 years ago

redstarcoder commented 7 years ago

Currently even implementing a simple button click can get a bit messy. This wouldn't be an issue if we had simple callbacks:

// KeyPress processes a KeyPress event
type KeyPressCallback func(key glfw.Key, action glfw.Action, mods glfw.ModifierKey)
OnKeyPress(callback KeyPressCallback)
// CharPress processes a character
type CharPressCallback func(char rune)
OnCharPress(callback CharPressCallback)
// MMove processes a MouseMove event
type MMoveCallback func(xpos, ypos float64)
OnMMove(callback MMoveCallback)
// MClick processes a MouseClick event
type MClickCallback func(xpos, ypos float64, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)
OnMClick(callback MClickCallback)