Hi,
I have the following Window/Widget structs:
Window struct {
*Widget
Children []*Widget
}
Widget struct {
X, Y int
Parent *Window
Type WidgetType
OnKeyPress func(KeyEvent)
This interface{} // This is very ugly, I think
}
TextBox struct {
*Widget
Text string
}
And in my event processing code I have:
for _, child := range window.Children {
if child.Type == TextBox && child.IsFocused() {
child.This.(*TextBox).Text += string(char)
}
}
This works but feels really wrong. Is there a better way to do this?
Thanks