-
Notifications
You must be signed in to change notification settings - Fork 43
/
event.go
37 lines (31 loc) · 845 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package gowd
//EventElement represents the DOM element sending an event
type EventElement struct {
Properties map[string]string `json:"properties"`
}
//Event represents a DOM event
type Event struct {
Name string `json:"name"`
Sender EventElement `json:"sender"`
Inputs []EventElement `json:"inputs"`
}
//EventHandler handler for DOM event.
type EventHandler func(sender *Element, event *EventElement)
const (
//OnClick onclick event
OnClick = "onclick"
//OnChange onchange event
OnChange = "onchange"
//OnKeyPress onkeypress event
OnKeyPress = "onkeypress"
)
//GetID get the id of the event sender.
func (e *EventElement) GetID() string {
id, _ := e.Properties["id"]
return id
}
//GetValue gets the value of the event sender.
func (e *EventElement) GetValue() string {
id, _ := e.Properties["value"]
return id
}