forked from fabioberger/chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathomnibox.go
More file actions
56 lines (45 loc) · 1.53 KB
/
omnibox.go
File metadata and controls
56 lines (45 loc) · 1.53 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package chrome
import "github.com/gopherjs/gopherjs/js"
type Omnibox struct {
o *js.Object
}
/*
* Types
*/
type SuggestResult struct {
*js.Object
Content string `js:"content"`
Description string `js:"description"`
}
/*
* Methods
*/
// SetDefaultSuggestion sets the description and styling for the default suggestion.
// The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar.
func (m *Omnibox) SetDefaultSuggestion(suggestion Object) {
m.o.Call("setDefaultSuggestion", suggestion)
}
/*
* Events
*/
// OnInputStarted user has started a keyword input session by typing the extension's keyword.
// This is guaranteed to be sent exactly once per input session, and before any onInputChanged events.
func (m *Omnibox) OnInputStarted(callback func()) {
m.o.Get("onInputStarted").Call("addListener", func() {
go func() {
callback()
}()
})
}
// OnInputChanged user has changed what is typed into the omnibox.
func (m *Omnibox) OnInputChanged(callback func(text string, suggest func(suggestResults []SuggestResult))) {
m.o.Get("onInputChanged").Call("addListener", callback)
}
// OnInputEntered user has accepted what is typed into the omnibox.
func (m *Omnibox) OnInputEntered(callback func(text string, disposition string)) {
m.o.Get("onInputEntered").Call("addListener", callback)
}
// OnInputCancelled user has ended the keyword input session without accepting the input.
func (m *Omnibox) OnInputCancelled(callback func()) {
m.o.Get("onInputCancelled").Call("addListener", callback)
}