Skip to content

Commit

Permalink
Add <Mouse> and <Keyboard> events
Browse files Browse the repository at this point in the history
Closes #190
  • Loading branch information
cjbassi committed Sep 15, 2018
1 parent 00d6843 commit fede2b0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit fede2b0

Please sign in to comment.