Skip to content

Commit

Permalink
Add prevent default to the event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed May 10, 2016
1 parent 7da0240 commit 73fb1fc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ func (e *Event) Int(key string) int {

// An EventListener can be attached to a HTML element to listen for events, mouse clicks etc.
type EventListener struct {
name string
listener func(*This, *Event)
// TODO(bep) prevent...
name string
listener func(*This, *Event)
preventDefault bool
delegate func(jsEvent *js.Object)
}

// PreventDefault prevents the default event behaviour in the browser.
func (l *EventListener) PreventDefault() *EventListener {
l.preventDefault = true
return l
}

// Listener is the signature for the func that needs to be implemented by the
// listener, e.g. the clickHandler etc.
type Listener func(*This, *Event)
Expand Down

0 comments on commit 73fb1fc

Please sign in to comment.