Add <Mouse> and <Keyboard> events

Closes #190
This commit is contained in:
Caleb Bassi 2018-09-15 12:10:53 -07:00
parent 00d684343a
commit fede2b0a74

View File

@ -26,6 +26,9 @@ Here's the list of events which can be assigned handlers using Handle():
<C-<Space>> etc
terminal events:
<Resize>
meta events:
<Keyboard>
<Mouse>
*/
type EventType int
@ -76,6 +79,16 @@ func handleEvent(e Event) {
if val, ok := defaultES.handlers[e.ID]; ok {
val(e)
}
switch e.Type {
case KeyboardEvent:
if val, ok := defaultES.handlers["<Keyboard>"]; ok {
val(e)
}
case MouseEvent:
if val, ok := defaultES.handlers["<Mouse>"]; ok {
val(e)
}
}
}
// Loop gets events from termbox and passes them off to handleEvent.